Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-29-2014, 10:35 AM
tammytran105 tammytran105 is offline Show/Hide Text based on Checkbox Selection Windows XP Show/Hide Text based on Checkbox Selection Office XP
Novice
Show/Hide Text based on Checkbox Selection
 
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Show/Hide Text based on Checkbox Selection Hide/Unhide a Block of Text Based on Choice Selection inquirer Word VBA 7 09-22-2014 04:41 PM
Show/Hide Text based on Checkbox Selection Hide Checkbox When Printing vinceplunkett Word 1 12-03-2013 01:53 AM
Show/Hide Text based on Checkbox Selection Show/hide paragraphs based on upfront decisions miscia76 Word 1 11-13-2013 04:29 PM
Show/Hide Text based on Checkbox Selection 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft