View Single Post
 
Old 09-29-2014, 10:35 AM
tammytran105 tammytran105 is offline Windows XP Office XP
Novice
 
Join Date: Sep 2014
Posts: 3
tammytran105 is on a distinguished road
Default Show/Hide Text based on Checkbox Selection

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
Reply With Quote