![]() |
|
#1
|
|||
|
|||
|
Hi,
I am trying to show/hide text based on whether a checkbox is selected. I was able to get this to work through using VBA and bookmarks, however, I need to have several checkboxes which have their own separate text to be shown if selected. This is where the problem is.. Each time one of the checkboxes if selected, ALL hidden text (which I've created separate bookmarks for) show instead of just the one dependent on what's been called out in the VBA code. Any help would be greatly appreciated!! This is the VBA I used for 5 checkboxes:Code:
Sub CheckBox2_Change()
Call ShowHideBookmark
End Sub
'
Sub ShowHideBookmark()
Dim orange As Range
Set orange = ActiveDocument.Bookmarks("mytext2").Range If CheckBox2.Value = True Then
With orange.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = True
End With
Else
With orange.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
End With
End If
End Sub
'
Sub CheckBox3_Change()
Call ShowHideBookmark3
End Sub
'
Sub ShowHideBookmark3()
Dim orange As Range
Set orange = ActiveDocument.Bookmarks("mytext3").Range
If CheckBox3.Value = True Then
With orange.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = True
End With
Else
With orange.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
End With
End If
End Sub
'
Sub CheckBox4_Change()
Call ShowHideBookmark4
End Sub
'
Sub ShowHideBookmark4()
Dim orange As Range
Set orange = ActiveDocument.Bookmarks("mytext4").Range
If CheckBox4.Value = True Then
With orange.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = True
End With
Else
With orange.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
End With
End If
End Sub
Last edited by macropod; 09-29-2014 at 08:53 PM. Reason: Added code tags & formatting |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Hide/Unhide a Block of Text Based on Choice Selection
|
inquirer | Word VBA | 7 | 09-22-2014 04:41 PM |
Hide Checkbox When Printing
|
vinceplunkett | Word | 1 | 12-03-2013 01:53 AM |
Show/hide paragraphs based on upfront decisions
|
miscia76 | Word | 1 | 11-13-2013 04:29 PM |
VBA for CheckBox to Hide Slides
|
mutchy25 | PowerPoint | 1 | 09-21-2012 01:40 AM |
| Macro to populate a text form field based on dropdown selection | koloa | Word | 0 | 10-20-2011 11:52 AM |