Jay
Fri Jul 04 20:55:11 CDT 2003
Hi, Jonathan,
Since you have the text and the summary in different styles, assuming those
styles are applied consistently and not applied to anything else in the
document, you can flip almost instantly just by changing the .Hidden property in
the styles. These two macros behave as expected for me (in Word 2003 beta),
using styles named Summary and Message:
Sub ShowMessages()
With ActiveDocument
.Styles("Message").Font.Hidden = False
.Styles("Summary").Font.Hidden = True
End With
End Sub
Sub ShowSummaries()
With ActiveDocument
.Styles("Message").Font.Hidden = True
.Styles("Summary").Font.Hidden = False
End With
End Sub
If you want a single macro so you can have a toggle button on a toolbar, it
would look like this:
Sub ToggleMessages()
With ActiveDocument
If .Styles("Summary").Font.Hidden = False Then
.Styles("Message").Font.Hidden = False
.Styles("Summary").Font.Hidden = True
Else
.Styles("Message").Font.Hidden = True
.Styles("Summary").Font.Hidden = False
End If
End With
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP Word MVP FAQ site:
http://www.mvps.org/word
Jonathan Sachs wrote:
> "Klaus Linke" <fotosatz_kaufmann@t-online.de> wrote:
>
>> Have you tried to select the table and use "Find/Replace"?
>>
>> Should be much faster, than working on each table cell, I think.
>
> There seems to be a lot of misunderstanding about what I'm trying to
> do. Let me give the entire context.
>
> I have a document which contains many tables, each representing the
> history of one auction I have conducted. Each row in a table
> represents one email message sent or received. One of the cells in
> each row contains (a) the entire text of the message, and (b) a
> one-line summary of the message. Text and summary are distinguished by
> different paragraph styles.
>
> Normally each message's summary is unhidden and its text paragraphs
> are hidden. This makes the table very compact and allows me to
> identify any message of interest. To display the contents of a
> message, I run a macro which hides its summary and unhides its text.
> When I am done with it, I run another macro which does the reverse.
>
> I designed these macros to hide (or unhide) the entire contents of
> cell, then unhide (or hide) the summary. That would have been almost
> instantaneous, which, given the macro's purpose, it needs to be. But
> for some reason I do not understand, trying to set the Hidden
> attribute for the entire text of the cell has no effect when done from
> a macro, although it works fine when done from the keyboard. (In case
> it matters, I am using Word 2000.)
>
> Now the macros iterate through the cell and hide or unhide each
> individual paragraph. This becomes very slow when the message is long.
> The 101-paragraph example which I mentioned is unusual, but real.
> Messages with a couple of dozen paragraphs are common.
>
> I'm trying to find a way to make the macros run much faster. I think
> it would be most productive to focus on how to set the Hidden
> attribute for all of the text in the cell.
>
> My mail address is jsachs177 at earthlink dot net.