Some time ago the following code was posted to this newsgroup as a way to
hide/display text based on its style.

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


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

I have created a document (attached) that has lines of text that are
alternately formatted using Summary Style or Message Style.
I find that the ShowMessages macro hides all text regardless of style and
ShowSummaries shows all rext regardless of style.
I feel I am doing something fundamentally wrong. Can you offer any
assistance?

Many Thanks
Tony Starr


PS. I am using Word xp

Re: Hidding test based on style by Klaus

Klaus
Thu Sep 29 12:23:51 CDT 2005

Hi Tony,

The attachment didn't make it to the MS news server, but it seems likely
that your "Message" style is based on the "Summary" style?

Regards,
Klaus



"Tony Starr" <tonystarrxxxnospamxxx@ozemail.com.au> wrote:
> Some time ago the following code was posted to this newsgroup as a way to
> hide/display text based on its style.
>
> 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
>
>
> 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
>
> I have created a document (attached) that has lines of text that are
> alternately formatted using Summary Style or Message Style.
> I find that the ShowMessages macro hides all text regardless of style and
> ShowSummaries shows all rext regardless of style.
> I feel I am doing something fundamentally wrong. Can you offer any
> assistance?
>
> Many Thanks
> Tony Starr
>
>
> PS. I am using Word xp
>
>



Re: Hidding test based on style by Klaus

Klaus
Fri Sep 30 08:49:35 CDT 2005

Hi Tony,

> I have included the attachment this time but without any macros in it.
> I don't think that my message style is based on my summary style but I
> might be wrong.

You had applied "hidden" as manual formatting on top of the "Message"
paragraphs.
The style itself was defined as "hidden", so "hidden+hidden=not hidden".

If you remove the manual formatting (Ctrl+A, Ctrl+Spacebar), the macros
should work.

> Could you please also explain to me why the following statements when run
> in the immediate window only hide the text formatted with the summary
> style
>
> activedocument.sections(2).range.font.Hidden = True
>
> and
>
> activedocument.bookmarks("mAllText").Range.Font.Hidden = True

Same reason: The two lines of code both apply "hidden" as manual formatting,
and since the "Message" style is already defined as "hidden", you get "not
hidden".

If you try to avoid manual formatting -- and do the toggling of style
visibility only through the style definitions -- you shouldn't run into
problems.

Good luck!
Klaus



Re: Hidding test based on style by Tony

Tony
Fri Sep 30 20:06:09 CDT 2005

Klaus,

You're a champion.

Thank you very much.
Tony




"Klaus Linke" <info@fotosatz-kaufmann.de> wrote in message
news:em9hXVcxFHA.720@TK2MSFTNGP15.phx.gbl...
> Hi Tony,
>
>> I have included the attachment this time but without any macros in it.
>> I don't think that my message style is based on my summary style but I
>> might be wrong.
>
> You had applied "hidden" as manual formatting on top of the "Message"
> paragraphs.
> The style itself was defined as "hidden", so "hidden+hidden=not hidden".
>
> If you remove the manual formatting (Ctrl+A, Ctrl+Spacebar), the macros
> should work.
>
>> Could you please also explain to me why the following statements when run
>> in the immediate window only hide the text formatted with the summary
>> style
>>
>> activedocument.sections(2).range.font.Hidden = True
>>
>> and
>>
>> activedocument.bookmarks("mAllText").Range.Font.Hidden = True
>
> Same reason: The two lines of code both apply "hidden" as manual
> formatting, and since the "Message" style is already defined as "hidden",
> you get "not hidden".
>
> If you try to avoid manual formatting -- and do the toggling of style
> visibility only through the style definitions -- you shouldn't run into
> problems.
>
> Good luck!
> Klaus
>
>