Adding tags to paragraph styles

R

Richard Wallace

I have a large Word document that has half a dozen styles applied to the
text, identifying each part of the text as a title, or heading, etc.

I want to add a visible tag (two letters in brackets, for example) to the
beginning of each paragraph indicating the style of that paragraph. Search
and replace makes it easy enough to find all text based on its style, but I
don't want to replace or delete the text - just add a tag.

Any way to globally accomplish this?

I'm using Word 2004 for Mac, Version 11.1.

Thanks!

Richard
 
D

Daiya Mitchell

Someone might come along with a more direct answer...but since there are few
things more frustrating than not being able to find something you know
exists:

<http://groups-beta.google.com/group/microsoft.public.word.word97vba/browse_
frm/thread/65c6f2be98e8d4a5/bd49b00b187bd7c0?q=name+styles+print+group:micro
soft.public.word.*+author:doug+author:robbins&rnum=1&hl=en#bd49b00b187bd7c0>

And also:

<http://groups-beta.google.com/group/microsoft.public.word.vba/browse_frm/th
read/f21c99830ae21a12/1da0ae34607adb97?q=name+styles+print+group:microsoft.p
ublic.word.*+author:doug+author:robbins&rnum=2&hl=en#1da0ae34607adb97>
 
M

matt neuburg

Richard Wallace said:
I have a large Word document that has half a dozen styles applied to the
text, identifying each part of the text as a title, or heading, etc.

I want to add a visible tag (two letters in brackets, for example) to the
beginning of each paragraph indicating the style of that paragraph. Search
and replace makes it easy enough to find all text based on its style, but I
don't want to replace or delete the text - just add a tag.

Any way to globally accomplish this?

Write a script. This will get you started, though you'll probably want
to modify it for your own purposes. This is how I XML-ize a Word
document (using paragraph styles):

tell application "Microsoft Word"
tell active document
set u to (count paragraphs)
end tell
repeat with x from 1 to u
tell active document
set s to (get style of paragraph x)
set s1 to "<" & s & ">"
set s2 to "</" & s & ">"
select character 1 of paragraph x
end tell
set r to (get text object of selection)
select (collapse range r direction collapse start)
set content of selection to s1
tell active document
select character -1 of paragraph x
end tell
set r to (get text object of selection)
select (collapse range r direction collapse start)
set content of selection to s2
end repeat
end tell

m.
 

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