Occasionally, I\'ll happen across a spreadsheet which suffers from magic buttons or listboxes which get bigger or smaller over time.
Nothing in the code is instructi
This problem is in fact due to screen resolution. Most commonly it occurs when the user connects to a projector, or WebEx while using the excel application.
A simple solution to this problem is to ask the user to reboot their machine without any peripheral connections (projector) and then open the excel application again.
This has been plaguing me for years, on and off. There are a number of fixes around, but they seem hit and miss. It was still occurring in Excel 2010 (happening to me May 2014), and is still occurring in Excel 2013 by some reports. The best description I have found that matches my situation at least (Excel 2010, no RDP involved, no Print Preview involved) is here:
Microsoft Excel Support Team Blog: ActiveX and form controls resize themselves when clicked or doing a print preview (in Excel 2010)
(This might not help for users of Excel 2013 sorry)
EDIT: Adding detail in case technet link ever goes dead, the technet article says:
FIRSTLY install Microsoft Hotfix 2598144 for Excel 2010, available: here.
SECONDLY, if your symptom is "An ActiveX button changes to the incorrect size after you click it in an Excel 2010 worksheet", then you should:
OR SECONDLY, if your symptom is "A button form control is displayed incorrectly in a workbook after you view the print preview of the workbook in Excel 2010", then you should:
OR SECONDLY, if your symptom is "An ActiveX button is changed to an incorrect size in an Excel 2010 worksheet after you view the print preview of the worksheet", then you should:
Good luck. This issue is such a pain...
I noticed that none of these answers anchor the control to a specific row and column. This has worked pretty cleanly for me as Rows/Columns tend to be more predictable than monitors' resolution.
The below sample basically "measures" where the object should go, then sets it there in the Worksheet_Activate
code. In the below example, the button will always snap to covering D8:F10
.
Private Sub Worksheet_Activate()
'Note this is done in the sheet code, not a Module.
With Me.Shapes("CommandButton1")
.Left = Me.Range("A1:C1").Width
.Top = Me.Range("a1:a7").Height
.Width = Me.Range("D1:F1").Width
.Height = Me.Range("A8:a10").Height
End With
End Sub
The result will appear as shown below:
I had a similar problem, however I found that it was quickly fixed by zooming the page in and out. Therefore, I added the below code onto the bottom of my Macro as a quick fix. I'm no Excel whizz but it seems to work ok. Change the bottom number should reflect your preferred zoom.
ActiveWindow.Zoom = 100
ActiveWindow.Zoom = 90
After trying many of the solutions on this and related posts, I discovered that the solution to a different problem that Microsoft had posted also worked reliably for this particular issue when applied in a particular way, at least within the context I'm working within. I experienced these problems in a resolution native to the laptops we have here and on a PC whenever I'd switch to a non-native resolution. Namely, buttons loading at a larger than normal size, getting larger when clicked on, and text and images in these buttons shrinking (and at least the setting for the text remained the same so I couldn't see any way to change it back programmatically or otherwise.) These have not been intermittent problems in my case. I have had intermittent problems though after using print preview which Microsoft has posted a solution for here. I've tried this and it seems to be working.
The solution: For Excel, close the app and delete the MSForms.exd file from C:\Users{UserName}\AppData\Local\Temp\Excel8.0
while in the resolution that you want to view the buttons in. You could also search for other .exd files in your local AppData\Temp folder for other Office apps.
As I mentioned, this is a solution proposed by Microsoft for a different issue - where the buttons stop working after the Dec '14 updates are installed. Here's the link to that article. In that case, it's a one time fix. Here, you may need to do it every time you change resolutions.
The fixes discussed earlier, programatically resizing/repositioning the Active X Controls after click events, or modifying the registry (with the D word LegacyAnchorResize), didn't solve the issue for me with Excel 2010/ Windows 7 64 bit.
The solution for me was found here:https://support.microsoft.com/en-us/kb/838006
For Excel 2010 the link instructs to: