Share via

Multi Step Wizard in Word 2016 using Visual Basic

Anonymous
2018-05-15T19:28:44+00:00

I am creating a user form for my client and he would like me to create a multi-step wizard. I am already using the Multi page option, but with one of the pages I want the user to get a question. If they answer "Yes", there is one set of questions. If they answer "No", there is another set of questions. Anyone know how can I create this without using a subset of tabs within the same page? Thanks in advance!

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

Answer accepted by question author

Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
2018-05-16T05:16:24+00:00

No, they are completely different.  In the following screen shot, the radio buttons have captions of Yes and No

While you could use a Command Button, as you want the display of the questions controlled by whether or not the user answers Yes or No to a question, radio buttons are the obvious thing to use.

If you are going to use a Command Button, which I would not, you would probably need two of them, one for Yes and another for No and you would have to use additional code to make the command buttons act in a mutually exclusive manner, which is simply done when using Radio Buttons by assigning them all to the one Group.

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

6 additional answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2018-05-15T22:58:09+00:00

    Best to have the Yes or No options as radio buttons to which you assign the same group name and then use code such as

    Private Sub optNo_Click()

    If optNo.Value = True Then

        lblQ1.Visible = True

        txtQ1.Visible = True 'the No question (Refer to additional questions and their related labels in the same way    lblQ2.Visible = False

    txtQ2.Visible = False 'The Yes question

    Else

        lblQ1.Visible=False

    txtQ1.Visible = False

        lblQ2.Visible = True

    txtQ2.Visible = True

    End If

    End Sub

    Private Sub optYes_Click()

    If optNo.Value = True Then

        lblQ1.Visible = False

    txtQ1.Visible = False

        lblQ2.Visible = True

    txtQ2.Visible = True

    Else

        lblQ1.Visible = True

    txtQ1.Visible = True 'the No question

        lblQ2.Visible = False

    txtQ2.Visible = False 'The Yes question

    End If

    End Sub

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2018-05-15T19:51:18+00:00

    Create a page for all questions, then hide the pages that you don't want to show.

    For example:

    Make an new file, add a Userform, add a Multipage with at min. 3 pages, create a Commandbutton anywhere, add this code:

    Private Sub CommandButton1_Click()
      Dim P As MSForms.Page
      Set P = Me.MultiPage1.Pages(1)
      P.Visible = True
    End Sub
    
    Private Sub UserForm_Initialize()
      Dim P As MSForms.Page
      Set P = Me.MultiPage1.Pages(1)
      P.Visible = False
    End Sub
    

    Run the form. As you see 2 pages, click the button... tadaa. :-)

    Any questions?

    Andreas.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  3. Anonymous
    2018-05-15T19:42:56+00:00

    You could create the two sets of questions on the form and turn visibility off. Then add code to the button that depending on what is selected to turn the visibility on for the correct flow of questions.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  4. Anonymous
    2018-05-15T20:08:06+00:00

    Thanks for your reply! Would you be able to give me an example of the button code? I am very new to the Visual Basic language.

    Was this answer helpful?

    0 comments No comments