Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I want to hide the last page of a document which I eventually want to
hide/unhide using a macro. I have created a 'Section Break (Next Page)' and created the last page of text, consisting of a heading and a table. I created a bookmark which includes the last section break through to the end of the document. I then select Bookmark and Goto my new bookmark. I format the Font as Hidden and all is well, with the last page (including its Header) disappearing. Now I select Bookmark, check Show Hidden, and Goto the bookmark. When I select Font the Hidden attribute is filled in so I check it and uncheck it. The table reappears but the section break, heading and last page header don't. If I show formatting they are still there but still hidden. PLEASE can anyone tell me what I'm doing wrong? Is it something to do with the section break operates?? |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
I could reproduce what you describe. Afterwards, I made several experiments
in order to try to find out what is going on. I found the following: Situation: You have a bookmark that contains text and tables. You hide the contents of the bookmark (Font Hidden). You go to the bookmark via the Bookmarks dialog box while hidden text is _not_ visible. Result: Only the part of the bookmark that starts with the first table and ends with the last table within the bookmark is selected, i.e. any text preceding or following the table(s) will not be selected. If you turn on formatting marks (Ctrl+Shift+8) immediately after you have selected goto bookmark, you will see that. On the other hand, if hidden text _is_ visible when you select goto bookmark, the bookmark is selected correctly. This seems to be a bug. As far as my tests showed, the section break is without importance. Note that if your last page does not have a different header/footer, you could actually skip the section break and just set your heading to start on a new page (Format Paragraph Line and Page Breaks Page break before). About €śHidden Bookmarks€ť in the Bookmark dialog box (if that is the one you refer to when you say €ścheck Show Hidden€ť) has nothing to do with hidden text. It determines whether the special bookmarks that Word creates when you insert e.g. a TOC or cross-references are shown in the list of bookmarks or not (start with e.g. _TOC or _Ref). The following macro should show or hide your bookmarked page correctly (if the user has formatting marks incl. hidden text shown, he/she will not see the result €“ therefore, you may want to keep track of whether the user has hidden text shown or not): Sub BookmarkedText_ShowHide() Dim oBookmark As Bookmark 'Insert the correct bookmark name instead of "MyBookmark" With ActiveDocument If .Bookmarks.Exists("MyBookmark") Then Set oBookmark = ActiveDocument.Bookmarks("MyBookmark") With oBookmark.Range .Font.Hidden = Not .Font.Hidden End With Else MsgBox "Cannot show/hide page - bookmark missing." End If End With Set oBookmark = Nothing End Sub -- Regards Lene Fredborg - Microsoft MVP (Word) DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "mpm1488" wrote: I want to hide the last page of a document which I eventually want to hide/unhide using a macro. I have created a 'Section Break (Next Page)' and created the last page of text, consisting of a heading and a table. I created a bookmark which includes the last section break through to the end of the document. I then select Bookmark and Goto my new bookmark. I format the Font as Hidden and all is well, with the last page (including its Header) disappearing. Now I select Bookmark, check Show Hidden, and Goto the bookmark. When I select Font the Hidden attribute is filled in so I check it and uncheck it. The table reappears but the section break, heading and last page header don't. If I show formatting they are still there but still hidden. PLEASE can anyone tell me what I'm doing wrong? Is it something to do with the section break operates?? |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Many thanks, Lene, I think I understand the bug you discovered. Also, thanks
for the tip on Hidden Bookmarks. When I tried your code it successfully unhid the full bookmark but didn't rehide it when run again. That's not a problem though as hiding the bookmark wasn't a problem and I already have a separate sub-routine for that. Many thanks for an elegant solution. "Lene Fredborg" wrote: I could reproduce what you describe. Afterwards, I made several experiments in order to try to find out what is going on. I found the following: Situation: You have a bookmark that contains text and tables. You hide the contents of the bookmark (Font Hidden). You go to the bookmark via the Bookmarks dialog box while hidden text is _not_ visible. Result: Only the part of the bookmark that starts with the first table and ends with the last table within the bookmark is selected, i.e. any text preceding or following the table(s) will not be selected. If you turn on formatting marks (Ctrl+Shift+8) immediately after you have selected goto bookmark, you will see that. On the other hand, if hidden text _is_ visible when you select goto bookmark, the bookmark is selected correctly. This seems to be a bug. As far as my tests showed, the section break is without importance. Note that if your last page does not have a different header/footer, you could actually skip the section break and just set your heading to start on a new page (Format Paragraph Line and Page Breaks Page break before). About €śHidden Bookmarks€ť in the Bookmark dialog box (if that is the one you refer to when you say €ścheck Show Hidden€ť) has nothing to do with hidden text. It determines whether the special bookmarks that Word creates when you insert e.g. a TOC or cross-references are shown in the list of bookmarks or not (start with e.g. _TOC or _Ref). The following macro should show or hide your bookmarked page correctly (if the user has formatting marks incl. hidden text shown, he/she will not see the result €“ therefore, you may want to keep track of whether the user has hidden text shown or not): Sub BookmarkedText_ShowHide() Dim oBookmark As Bookmark 'Insert the correct bookmark name instead of "MyBookmark" With ActiveDocument If .Bookmarks.Exists("MyBookmark") Then Set oBookmark = ActiveDocument.Bookmarks("MyBookmark") With oBookmark.Range .Font.Hidden = Not .Font.Hidden End With Else MsgBox "Cannot show/hide page - bookmark missing." End If End With Set oBookmark = Nothing End Sub -- Regards Lene Fredborg - Microsoft MVP (Word) DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "mpm1488" wrote: I want to hide the last page of a document which I eventually want to hide/unhide using a macro. I have created a 'Section Break (Next Page)' and created the last page of text, consisting of a heading and a table. I created a bookmark which includes the last section break through to the end of the document. I then select Bookmark and Goto my new bookmark. I format the Font as Hidden and all is well, with the last page (including its Header) disappearing. Now I select Bookmark, check Show Hidden, and Goto the bookmark. When I select Font the Hidden attribute is filled in so I check it and uncheck it. The table reappears but the section break, heading and last page header don't. If I show formatting they are still there but still hidden. PLEASE can anyone tell me what I'm doing wrong? Is it something to do with the section break operates?? |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
You are welcome.
Could it be that you had hidden text set to visible (formatting marks) when you tested the macro? In that case, the text will still be visible even if the font is set to hidden but you will see a tiny dotted line below the text which indicates that it is marked as hidden. -- Regards Lene Fredborg - Microsoft MVP (Word) DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "mpm1488" wrote: Many thanks, Lene, I think I understand the bug you discovered. Also, thanks for the tip on Hidden Bookmarks. When I tried your code it successfully unhid the full bookmark but didn't rehide it when run again. That's not a problem though as hiding the bookmark wasn't a problem and I already have a separate sub-routine for that. Many thanks for an elegant solution. "Lene Fredborg" wrote: I could reproduce what you describe. Afterwards, I made several experiments in order to try to find out what is going on. I found the following: Situation: You have a bookmark that contains text and tables. You hide the contents of the bookmark (Font Hidden). You go to the bookmark via the Bookmarks dialog box while hidden text is _not_ visible. Result: Only the part of the bookmark that starts with the first table and ends with the last table within the bookmark is selected, i.e. any text preceding or following the table(s) will not be selected. If you turn on formatting marks (Ctrl+Shift+8) immediately after you have selected goto bookmark, you will see that. On the other hand, if hidden text _is_ visible when you select goto bookmark, the bookmark is selected correctly. This seems to be a bug. As far as my tests showed, the section break is without importance. Note that if your last page does not have a different header/footer, you could actually skip the section break and just set your heading to start on a new page (Format Paragraph Line and Page Breaks Page break before). About €śHidden Bookmarks€ť in the Bookmark dialog box (if that is the one you refer to when you say €ścheck Show Hidden€ť) has nothing to do with hidden text. It determines whether the special bookmarks that Word creates when you insert e.g. a TOC or cross-references are shown in the list of bookmarks or not (start with e.g. _TOC or _Ref). The following macro should show or hide your bookmarked page correctly (if the user has formatting marks incl. hidden text shown, he/she will not see the result €“ therefore, you may want to keep track of whether the user has hidden text shown or not): Sub BookmarkedText_ShowHide() Dim oBookmark As Bookmark 'Insert the correct bookmark name instead of "MyBookmark" With ActiveDocument If .Bookmarks.Exists("MyBookmark") Then Set oBookmark = ActiveDocument.Bookmarks("MyBookmark") With oBookmark.Range .Font.Hidden = Not .Font.Hidden End With Else MsgBox "Cannot show/hide page - bookmark missing." End If End With Set oBookmark = Nothing End Sub -- Regards Lene Fredborg - Microsoft MVP (Word) DocTools - Denmark www.thedoctools.com Document automation - add-ins, macros and templates for Microsoft Word "mpm1488" wrote: I want to hide the last page of a document which I eventually want to hide/unhide using a macro. I have created a 'Section Break (Next Page)' and created the last page of text, consisting of a heading and a table. I created a bookmark which includes the last section break through to the end of the document. I then select Bookmark and Goto my new bookmark. I format the Font as Hidden and all is well, with the last page (including its Header) disappearing. Now I select Bookmark, check Show Hidden, and Goto the bookmark. When I select Font the Hidden attribute is filled in so I check it and uncheck it. The table reappears but the section break, heading and last page header don't. If I show formatting they are still there but still hidden. PLEASE can anyone tell me what I'm doing wrong? Is it something to do with the section break operates?? |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Hiding Text from View | Microsoft Word Help | |||
Hiding Text | Microsoft Word Help | |||
Hiding Caption Text | Microsoft Word Help | |||
Hiding and unhiding headers and footers | Page Layout | |||
Track changes should show added text while HIDING deleted text. | Microsoft Word Help |