Consulting

Results 1 to 2 of 2

Thread: Show/Hide paragraph in word if Checkbox selected

  1. #1
    VBAX Regular
    Joined
    Jul 2014
    Posts
    54
    Location

    Question Show/Hide paragraph in word if Checkbox selected

    Hi

    Thanks for reading. I'm very new to VBA, less than a week, so please bear with me if my query doesn't make sense.

    I have a standardised form ("Notice") that I use for work, which up until now has just been completed and amended by hand. I have been able to design a Userform which Initialises immediately when the Notice is opened and which contains textboxes for name, address and so on.

    At the end of the Notice, there can be three possible final paragraphs dependant upon what the user needs. What I'd like to be able to do is to add three checkboxes to my Userform so that if one is selected, when I then press 'OK' and the DocVariables are updated in the Notice, the document would show the relevant paragraph. I've seen mention made of using hidden text and also using bookmarks - though I haven't quite been able to figure out how to make it work. One thing I would mention is that I don't have network access to create Autotexts or access the Building Blocks Organiser.

    I would be so grateful if someone could point me in the right direction to solving this.

    Thanks again.

    Dav

  2. #2
    VBAX Tutor
    Joined
    Mar 2014
    Posts
    210
    Location
    You could put the texts in text boxes. All are hidden , except the one you want...
    Sub Show1Box(ByVal pyBoxNum As Byte)
    Dim shp
    For Each shp In ActiveDocument.Shapes
        shp.Visible = shp.Name = "txtBox" & pyBoxNum
    Next
    End Sub
    Sub ShowAllTextBoxes()
    For Each shp In ActiveDocument.Shapes
         shp.Visible = True
    Next
    End Sub
    Sub NumberAllBoxes()
    For Each shp In ActiveDocument.Shapes
       i = i + 1
       shp.Name = "txtBox" & i
       'MsgBox shp.TextFrame.TextRange.Text, , shp.Name
    Next
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •