#1   Report Post  
Posted to microsoft.public.word.docmanagement
mpm1488 mpm1488 is offline
external usenet poster
 
Posts: 2
Default Hiding / Unhiding text

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   Report Post  
Posted to microsoft.public.word.docmanagement
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Hiding / Unhiding text

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   Report Post  
Posted to microsoft.public.word.docmanagement
mpm1488 mpm1488 is offline
external usenet poster
 
Posts: 2
Default Hiding / Unhiding text

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   Report Post  
Posted to microsoft.public.word.docmanagement
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Hiding / Unhiding text

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding Text from View smcb13 Microsoft Word Help 5 July 10th 08 03:53 PM
Hiding Text Darren Microsoft Word Help 1 December 6th 07 01:36 AM
Hiding Caption Text Paul L. Microsoft Word Help 7 October 24th 06 02:17 PM
Hiding and unhiding headers and footers kurt Page Layout 1 September 21st 05 01:59 AM
Track changes should show added text while HIDING deleted text. Janet at Boeing Microsoft Word Help 6 June 3rd 05 03:22 AM


All times are GMT +1. The time now is 11:56 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"