A
Anne P.
Hi,
I have been doing customizations for companies (mostly law firms) from Word 6 through 2000. When setting up their styles, I use the following method:
First, I insert dummy text by typing =and(10,5) to insert 10 paragraphs, with 5 sentences each. Then, in each paragraph, I apply the required formatting and save the style name.
When I am done, I have a bunch of paragraphs with the text: "The quick brown fox jumps over .", and it is not clear what style is applied without looking at the stylename name drop-down list.
So, I created the following macro which loops through all paragraphs in the document. It turns on the Bold attribute, inserts the name of the style at the beginning of the paragraph and then turns off the Bold attribute.
Sub StyleName()
Dim opara As Paragraph
For Each opara In ActiveDocument.Paragraphs
If opara.Style <> "Normal" Then
Selection.Font.Bold = wdToggle
opara.Range.InsertBefore Text:=Format(opara.Style.NameLocal & ". ")
Selection.Font.Bold = wdToggle
End If
Next opara
End Sub
This method has worked very good for Word 97 and Word 2000. However, it does not work for Word XP or Word 2003. I have split the window and watched how it works as I step through the macro (pressing F8). I see it turn bold on, then it goes to the beginning of the paragraph (before the bold on command which effectively turns bold off), inserts the name of the style, then does the Bold toggle, but since it was just turned off before it inserted the text, it is now turning Bold on after the text has been inserted and the text is not bold.
Any suggestions on how I can make this work in Word 2003?
Thanks,
Anne
I have been doing customizations for companies (mostly law firms) from Word 6 through 2000. When setting up their styles, I use the following method:
First, I insert dummy text by typing =and(10,5) to insert 10 paragraphs, with 5 sentences each. Then, in each paragraph, I apply the required formatting and save the style name.
When I am done, I have a bunch of paragraphs with the text: "The quick brown fox jumps over .", and it is not clear what style is applied without looking at the stylename name drop-down list.
So, I created the following macro which loops through all paragraphs in the document. It turns on the Bold attribute, inserts the name of the style at the beginning of the paragraph and then turns off the Bold attribute.
Sub StyleName()
Dim opara As Paragraph
For Each opara In ActiveDocument.Paragraphs
If opara.Style <> "Normal" Then
Selection.Font.Bold = wdToggle
opara.Range.InsertBefore Text:=Format(opara.Style.NameLocal & ". ")
Selection.Font.Bold = wdToggle
End If
Next opara
End Sub
This method has worked very good for Word 97 and Word 2000. However, it does not work for Word XP or Word 2003. I have split the window and watched how it works as I step through the macro (pressing F8). I see it turn bold on, then it goes to the beginning of the paragraph (before the bold on command which effectively turns bold off), inserts the name of the style, then does the Bold toggle, but since it was just turned off before it inserted the text, it is now turning Bold on after the text has been inserted and the text is not bold.
Any suggestions on how I can make this work in Word 2003?
Thanks,
Anne