Table won't hide

G

Gordon Bentley-Mix

Here's an odd one for you all:

Word 2003 under Windows XP

I have a template set up to toggle the visibility of certain portions of the
document depending on the values input through a UserForm. For example, if
the "Goods Schedule" checkbox is selected, the related "Goods Schedule" page
is displayed; if the checkbox isn't selected, then the page is hidden. This
is accomplished by wrapping the content in a bookmark and setting the Hidden
property of the Font bookmark's Range. I do this a lot, so I've written a
couple of "generic" procedures that accept arguments for toggling the
visibility, as follows:

Public Sub HideBookmarkRange(BkmkName As String)
With myDoc
If .Bookmarks.Exists(BkmkName) Then
..Bookmarks(BkmkName).Range.Font.Hidden = True
End With
End Sub

Public Sub ShowBookmarkRange(BkmkName As String)
With myDoc
If .Bookmarks.Exists(BkmkName) Then
..Bookmarks(BkmkName).Range.Font.Hidden = False
End With
End Sub

In some cases the content is a portion of a table (one or more rows), but of
course it's impossible to wrap a bookmark around a single row or several rows
within a table. In these instances, I've spilt the table at the appropriate
points and wrapped the bookmark around the whole table, including the
paragraph before the table. This works _most_ of the time.

HOWEVER... One table refuses to hide. The text within the table is formatted
as hidden, but the table itself is still visible. I've tried adding a
paragraph after the table and including this paragraph in the bookmark, and
I've even tried manually setting the font to hidden. Nothing seems to work.

As far as I can tell, this table is no different from any of the others in
the template. All of the properties are the same; the style applied to the
paragraph before the table is the same; and there are no styles applied to
any of the content within the table that aren't used in other tables
elsewhere.

Any ideas as to why this table and this table only refuses to play nice and
hide like the rest of them do?
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
G

Gordon Bentley-Mix

BTDT. Same result. I even copied (and slightly modified) a table that works
and still no joy. At least I *think* it was a table that works; might have
to check again when I get to work tomorrow.

Thanks for the suggestion!
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
G

Gordon Bentley-Mix

Sadly this still does not resolve the problem. Even repurposing a table that
I *know* hides properly under the correct conditions, the process still only
hides the text within the table and not the table itself.

~sigh~

Oh well. It looks a bit odd, but I guess I'll just have to live with it.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
D

Doug Robbins - Word MVP

Gordon,

If having the space occupied by the table remain in the document, you could
set the colour of the font and the borders to white.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Gordon Bentley-Mix

Hmm... Won't quite work unfortunately. It's a "row" in the middle of a larger
table, and the goal is to make it look like one continuous table - either
with or without the "row" in question, depending on the info from the
UserForm. A white gap in the middle might be a bit noticeable... ;-P

Good idea though, but I think I'll just stay with the blank row. At least
that way the continuity of the table remains intact. The gap before and after
the table uses a style with a 1pt height and 1pt, hidden font and there is no
top or bottom border on the table, so it just closes everything up when the
doc is printed.

Thanks Doug!
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
J

Janine

GBM
I found this hide/show code - does it help?

Public Sub HideShow()

'The following code does not require that the whole of the table be _
included in the bookmark

Dim sBookmark As String
sBookmark = "Table"
If ActiveDocument.Bookmarks.Exists(sBookmark) = False Then
MsgBox "The Bookmark " & Chr(34) & sBookmark & Chr(34) & " does not
exist."
Exit Sub
End If
With ActiveDocument.Bookmarks(sBookmark).Range.Tables(1).Range.Font
If .Hidden = True Then
.Hidden = False
Else
.Hidden = True
End If
End With
End Sub

Janine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top