![]() |
#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. ![]() 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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
inquirer | Word VBA | 7 | 09-22-2014 04:41 PM |
![]() |
vinceplunkett | Word | 1 | 12-03-2013 01:53 AM |
![]() |
miscia76 | Word | 1 | 11-13-2013 04:29 PM |
![]() |
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 |