Hide table using Range

C

Charles Kenyon

I would like to change all the text in a table to hidden text without
selecting the table. Can I do this using a range? How?

I know I can hide the table using
ActiveDocument.Tables(3).Select
Selection.Font.Hidden = True

If it matters, the code I'm writing should work in Word 97, 2000, 2002 &
2003.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
C

Charles Kenyon

Hi,

I should have checked the MVP FAQ before I asked. I found the code there.

For Each oCell In oTable.Range.Cells
oCell.Range.Font.Hidden = bMark
Next oCell

<URL: http://www.mvps.org/word/FAQs/MacrosVBA/ChangAllCellsInTbl.htm>

Thank you Bill Coan!
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
K

Klaus Linke

Hi Charles,

Yes -- the trick is that the end-of-row-marker shouldn't be formatted as
"hidden".
Else, the whole row will be hidden.

In a large table, "for each row" might be noticeably faster than "for each
cell" (... though I haven't timed it):

Dim myRow As Row
With ActiveDocument.Tables(1)
.Range.Font.Hidden = True
' unhide end-of-row-markers:
For Each myRow In .Range.Rows
myRow.Range.Characters.Last.Font.Hidden = False
Next myRow
End With
End Sub

Greetings,
Klaus
 

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