Reverse macro below

J

Jerry

I have this macro that displays the style name for all
paragraphs in a document. I use this to easily check to
make sure certain styles are used. Is there a way to
reverse this and have the style name removed?

Thanks

Sub TagParas()

Dim p As Paragraph
Dim sText As String
Dim sStyle As String

For Each p In ActiveDocument.Paragraphs
sStyle = p.Style
p.Range.InsertBefore "@" + sStyle + " = "
Next p

End Sub
 
J

Jean-Guy Marcil

Jerry was telling us:
Jerry nous racontait que :
I have this macro that displays the style name for all
paragraphs in a document. I use this to easily check to
make sure certain styles are used. Is there a way to
reverse this and have the style name removed?

Thanks

Sub TagParas()

Dim p As Paragraph
Dim sText As String
Dim sStyle As String

For Each p In ActiveDocument.Paragraphs
sStyle = p.Style
p.Range.InsertBefore "@" + sStyle + " = "
Next p

End Sub

Instead of doing this, why don't you display the document in Normal view,
and in the Tools menu > Options > Set the "Style area width" to 1 inch or
so?
Then when you want to scan for styles, just switch to normal view.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
H

Helmut Weber

Hi Jerry,

just for fun.
If it has to be:

Sub Test764()
Dim p As Paragraph
Dim r As Range
For Each p In ActiveDocument.Paragraphs
Set r = p.Range
r.End = r.start + Len(p.Style) + 4
r.Delete
Next p
End Sub

But I'd rather use Jean-Guy's method.

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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