0

I have a macro that performs a number of functions and works properly, but the buttons resize in one of two situations. The buttons reize when the macro uses an autofilter, which deletes roughly 500 rows of data (the buttons get much larger), and they also resize when I first paste in the data before I run the program (once again get larger). I have tried going into properties and selecting "Don't move or size with the cells" in object positioning. I have also tried locking the aspect ratio of the buttons. But neither have kept the button from resizing. Any ideas of what else I could try?

4

1 回答 1

2

我认为这应该可以解决问题。

我之前见过的另一件事是,如果按钮发生变化,字体大小有时会发生变化。我包括了这个,但把它注释掉了。您可能还希望/需要重置按钮的.TopLeftCell位置,这也包括在内,但在下面的代码中注释掉了:

'## Add the following to your existing macro:
Dim btn As Shape
Dim btLeft As Double, btTop As Double, btWidth As Double, _
    btHeight As Double, btFontSize As Double
Dim btCell As Range

'## Put this block of code before your existing code:
Set btn = ActiveSheet.Shapes("Button 3") '## Modify to your button name
With btn
    btLeft = .Left
    btTop = .Top
    btHeight = .Height
    btWidth = .Width
    'btFontSize = TextFrame2.TextRange.Font.Size
    'Set btCell = btn.TopLeftCell
End With

'Your code goes here:
'
'
'
'End of your code

'## Put this block of code before the Exit Sub statement/after your existing code
With btn
    '.TopLeftCell = btCell
    '.TextFrame2.TextRange.Font.Size = btnFontSize
    .Left = btLeft
    .Top = btTop
    .Height = btHeight
    .Width = btWidth
End With
于 2013-07-08T16:52:55.467 回答