Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide / Show Bookmarks in Word

Status
Not open for further replies.

remeng

Technical User
Jul 27, 2006
504
0
16
US
All;

I have a weird problem when showing and hiding a bookmark in Word 2010. So here is what is going on. My code for showing and hiding AppendixD is working correctly when the document is being used. Once the document is saved, closed, and then re-opened, a table within the AppendixD bookmark is still being shown. The contents of the table are correctly hidden. It is just the outline of a table. I added AppendixD_Sub just around the table and contents to check to see what might be going on, but the table outline is still showing once you saved, closed, and then re-opened the document.

I have also tried to:

1) remove the Bookmark
2) remove the table
3) recreate the table
4) recreate the bookmark

The problem still occurs after those steps.

Any ideas on how to fix this?


Code:
Private Sub FCA_Overseas_Click()

Application.ScreenUpdating = False

If FCA_Overseas.Value = True Then

ActiveDocument.Bookmarks("AppendixD").Range.Font.Hidden = False
ActiveDocument.Bookmarks("AppendixD_Sub").Range.Font.Hidden = False
ActiveDocument.Bookmarks("DAP").Range.Font.Hidden = True
ActiveDocument.Bookmarks("FCA").Range.Font.Hidden = False
ActiveDocument.Bookmarks("SAW").Range.Font.Hidden = True

Trad_Order.Value = True
SAW_Flow.Value = False
SAF_Flow.Value = False
Trans_Supplier.Value = False
FCA_Incoterm.Value = True
MilkRun.Value = False

Else

ActiveDocument.Bookmarks("AppendixD").Range.Font.Hidden = True
ActiveDocument.Bookmarks("AppendixD_Sub").Range.Font.Hidden = True
ActiveDocument.Bookmarks("DAP").Range.Font.Hidden = False
ActiveDocument.Bookmarks("FCA").Range.Font.Hidden = False
ActiveDocument.Bookmarks("SAW").Range.Font.Hidden = False


Trad_Order.Value = False
SAW_Flow.Value = False
SAF_Flow.Value = False
Trans_Supplier.Value = False
FCA_Incoterm.Value = False
MilkRun.Value = False


End If

Call TofC_Update

Application.ScreenUpdating = True

End Sub

Thanks,

Mike
 
Since you are talking VBA, you may want to post your question in forum707

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Hi,

I found a work around. It might not be the correct way of doing it, but it works so there it is.

The new code executes when the document is opened. If AppendixD is supposed to be hidden based of the saved conditions, it will refresh the document which will hide that table section. If AppendixD is supposed to be show, the Else statement is used.

Code:
Sub Document_Open()

Application.ScreenUpdating = False

If ISPM15_Box.Value = True Or FCA_Overseas.Value = True Then

ActiveDocument.Bookmarks("AppendixD").Range.Font.Hidden = False


Else

ActiveDocument.Bookmarks("AppendixD").Range.Font.Hidden = True


End If

Call TofC_Update

Application.ScreenUpdating = True

End Sub
 
You may have it shorter:

Code:
Sub Document_Open()

Application.ScreenUpdating = False

ActiveDocument.Bookmarks("AppendixD").Range.Font.Hidden = _
    (ISPM15_Box.Value Or FCA_Overseas.Value)

Call TofC_Update

Application.ScreenUpdating = True

End Sub
... but if it works, then it is up to you.

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top