How can I wrap some text, with formatting, with some xml tags in .

P

peace4theapes

Hello everybody,
I need to surround some formatted text in WORD, with some xml tags. What I
mean here is that I have a document with different formatting, and I want to
wrap some tags around the text of some specific format. I am doing this so as
to parse the data from the document, which would be easy with the tags. It
would be great if someone gave me the regular expressions too.

Thanks,
peace4theapes
 
V

Vince

Sounds like the document is styled, so why not loop through the styles and
tag them as well?
 
P

peace4theapes

Vince,
That is what I would like to do. Surround different styles with different
tags and it will be easier to parse. I thought I could use the find and
replace function for each style, but cannot figure out the regular
expression. Could you give me any further info please?

Thanks,
peace4theapes
 
V

Vince

Why not just do this?

Dim ST As Style

For Each ST In ActiveDocument.Styles
With ActiveDocument.Content.Find
.ClearFormatting
.Style = ST

With .Replacement
.text = "<" & ST & ">" & "^&" & "</" & ST & ">"
End With

.Execute Replace:=wdReplaceAll
End With
Next

You can do any clean up after this....
 

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