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 very frustrating, my experience is that the properties are usually set properly on the ActiveX objects. I've modified a UDF from above to just be able to run on any active sheet, this will set everything back the way it was before shrinking.
Public Sub ResizeAllOfIt()
Dim myCtrl As OLEObject
For Each myCtrl In ActiveSheet.OLEObjects
Dim originalHeight
Dim originalWidth
originalWidth = myCtrl.width
originalHeight = myCtrl.height
myCtrl.height = originalHeight - 1
myCtrl.height = originalHeight
myCtrl.width = originalWidth
Next myCtrl
End Sub
[EXCEL PROFESSIONAL PLUS 2016, 32BITS, VERSION 1802, BUILD 9029.2167]
I was having the same issue and I could solve the problem by customizing the display scaling in windows 10, 64 bits. It is extremelly simple and it works for a single user. Just follow the instructions below and you will have all the Form Controls, sheet shapes, figures and ActiveX Controls back to their original size. No need to coding or doing advanced trickery/wizardry/hacks. If the provided link is broken, just repeat these steps.
To Set Display Custom Scaling in Windows 10, you need to do the following.
Open Settings.
It is an old post, but I hope it helps anyone who is dealing with this annoying and stressing Excel problem.
https://winaero.com/blog/set-display-custom-scaling-windows-10/
After searching the net, it seams the best solution is saving the file as .xlsb (binary) rather than .xlsm
What I started doing a while back was to have a single sub that sets the size of all my controls. I can then run this sub from any point in the code where the controls grow or shrink. It's sometimes a lot of extra finicky work, but it keeps my buttons from eating my spreadsheet.
Could it be that the button is defined to stick to the corners of a cell, instead of floating freely ?
Check it with
Format | Properties | Object Positioning
and choose anything but "move and size with cells"
We just solved this on a company level by adding the following module to all macro enabled workbooks:
Option Explicit
Type ButtonSizeType
topPosition As Single
leftPosition As Single
height As Single
width As Single
End Type
Public myButton As ButtonSizeType
Sub GetButtonSize(cb As MSForms.CommandButton)
' Save original button size to solve windows bug that changes the button size to
' adjust to screen resolution, when not in native resolution mode of screen
myButton.topPosition = cb.top
myButton.leftPosition = cb.Left
myButton.height = cb.height
myButton.width = cb.width
End Sub
Sub SetButtonSize(cb As MSForms.CommandButton)
' Restore original button size to solve windows bug that changes the button size to
' adjust to screen resolution, when not in native resolution mode of screen
cb.top = myButton.topPosition
cb.Left = myButton.leftPosition
cb.height = myButton.height
cb.width = myButton.width
End Sub
Just call them in the beginning and end of your code like this:
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
' Turn off ScreenUpdating to make sure the user dosn't see the buttons flicker
GetButtonSize CommandButton1 ' Saves original button size
' Do cool things
'
'
'
SetButtonSize CommandButton1 ' Restores original button size
Application.ScreenUpdating = True
' Turn ScreenUpdating back on when you're done
End Sub