Share via

Shrinking text size when using VBA command button on a form

Anonymous
2012-01-30T22:36:17+00:00

Inserted command buttons from VBA toolbar into my Excel user page and have associated code with the buttons.  Code works fine but everytime I select a command button the font decreases.  I go in and verfiy that my properties have correct font and font size selected.  I have seen this same question on web searches but no answer on how to fix it and to keep a command button.  Help would be appreciated.  Thks, Pete

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2012-02-24T16:18:41+00:00

I had this problem; the font size value stays the same but the text shrinks - wierd.

I solved it by making the AutoSize = True. Unfortunately the buttons are different sizes, but at least they are readable.

Was this answer helpful?

7 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2012-02-20T10:14:57+00:00

    Hi,

    Thank you for posting.

    To stop from shrinking text size in the CommandButton everytime you click, please refer to the following code:

    'To save the original font size in CommandButton1.

    Dim curFontSize As Currency

    '###############################################################

    'Set the text size in CommandButton1 back to the recorded text size.

    '###############################################################

    Private Sub CommandButton1_Click()

        CommandButton1.Font.Size = curFontSize

    End Sub

    '#################################################

    'Record the original text size in CommandButton1.

    '#################################################

    Private Sub UserForm_Initialize()

        curFontSize = CommandButton1.Font.Size

    End Sub

    have a great day!

    Cristin Yan

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments