Share via

Word VBA command button problem.

Anonymous
2014-03-27T22:50:51+00:00

Hi there, Im really hoping someone could help me with this little problem. I want to show a userform using an ActiveX CommandButton, the code is correct and the button works only once. After I clicked it once the anchor symbol appears and it doesnt let me click on the button so I cant open the userform. I think that the command button layout may be the problem, but dont really know...

The userform only has 3 buttons which helps the user navigate through the document:

"Selection.GoTo wdGoToPage, wdGoToAbsolute, /pagenumber"

Thankyou 

Rogelio P.

Microsoft 365 and Office | Word | 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

3 answers

Sort by: Most helpful
  1. Anonymous
    2014-03-28T04:45:25+00:00

    From what I know the problem is with the code of the buttons on the userform, if I perfom other action than go to a page the button does work multiple times.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-03-28T04:42:24+00:00

    Hi there Doug thanks for your reply. The button has the following code:

    Private Sub CommandButton1_Click()

    UserForm1.show

    End Sub

    The problem with adding a button to the QAT is that this file is not for me, its to be emailed to a bunch of userrs.

    Was this answer helpful?

    0 comments No comments
  3. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2014-03-28T04:31:43+00:00

    What is the code that is run by the button.

    Here, if I add a command button to a document that is based on the Normal.dotm template and have the following code on that button

    Private Sub CommandButton1_Click()

    Application.Run "Normal.modCalendar.Calendar"

    End Sub

    and in the Normal.dotm template, I have a module modCalendar that contains the code

    Public strDate As String

    Sub Calendar()

    Dim mycalform As frmCalendar

    Set mycalform = New frmCalendar

    mycalform.Show

    Set mycal = Nothing

    Selection.InsertBefore strDate

    End Sub

    and there is a frmCalendar in the Normal.dotm template, I can use the Command Button multiple times and each time, the frmCalendar is displayed.  The anchor symbol does appear alongside the Command Button, each time it has the focus (is clicked)

    I would suggest however that rather than use an ActiveX Command Button, you add a button to the QAT that contains the code to cause the UserForm to be displayed

    Was this answer helpful?

    0 comments No comments