quant2009
04-05-2013, 04:00 AM
Hi all, would be grateful if someone could point out what I'm missing here.
Creating a doc' where blocks of text are hidden or shown according to user preference with togglebuttons for each block of text. Code as follows:-
Sub ShowHideBookmark()
Dim para1 As Range, para2 As Range
Set para1 = ActiveDocument.Bookmarks("CWIND_DETAIL").Range
Set para2 = ActiveDocument.Bookmarks("DLG_DETAIL").Range
If ToggleButton1.Value = False Then
With para1.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
End With
Else
With para1.Font
.Hidden = False
End With
With ActiveWindow.View
.ShowHiddenText = True
End With
End If
If ToggleButton2.Value = False Then
With para2.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
End With
Else
With para2.Font
.Hidden = False
End With
With ActiveWindow.View
.ShowHiddenText = True
End With
End If
End Sub
However, when I click one button to show or hide the text, both the blocks of text are shown or hidden - so each toggle button activates all the bookmarks. I need to attribute a further 3 togglebuttons (5 in total) to specific blocks of bookmarked text. Any suggestions would be very much appreciated.
Creating a doc' where blocks of text are hidden or shown according to user preference with togglebuttons for each block of text. Code as follows:-
Sub ShowHideBookmark()
Dim para1 As Range, para2 As Range
Set para1 = ActiveDocument.Bookmarks("CWIND_DETAIL").Range
Set para2 = ActiveDocument.Bookmarks("DLG_DETAIL").Range
If ToggleButton1.Value = False Then
With para1.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
End With
Else
With para1.Font
.Hidden = False
End With
With ActiveWindow.View
.ShowHiddenText = True
End With
End If
If ToggleButton2.Value = False Then
With para2.Font
.Hidden = True
End With
With ActiveWindow.View
.ShowHiddenText = False
End With
Else
With para2.Font
.Hidden = False
End With
With ActiveWindow.View
.ShowHiddenText = True
End With
End If
End Sub
However, when I click one button to show or hide the text, both the blocks of text are shown or hidden - so each toggle button activates all the bookmarks. I need to attribute a further 3 togglebuttons (5 in total) to specific blocks of bookmarked text. Any suggestions would be very much appreciated.