Search for XML tags in a Word document

B

bunyip

Hi,
I am a complete XML newbie. I have an XML template open
in Word 2003 and I would like to use a macro to copy and
paste text from another word document into the template
and then save it as a Word document. I need to know how
(if possible) to search for individual XML schema tags so
I can paste the text into them. Would realy appreciate
any help that anyone can offer.

Many thanks in advance.
 
C

Charles Maxson

bunyip,

Your choices are using using XPath to locate nodes:

ActiveDocument.SelectSingleNode("//EmployeeName", sNameSpace).Range = sText



OR

You can loop thru all nodes in the document using the XmlNode object looking
for a match:



Sub InsertIntoNode()

AddTextXmlNode "EmployeeName", "John Doe"

End Sub


Sub AddTextXmlNode(sNode, sText)
Dim xNode As xmlnode

For Each xNode In ActiveDocument.XMLNodes
If xNode.BaseName = sNode Then
xNode.Range.Text = sText
End If
Next

End Sub
 
G

Guest

Thank you very much Charles. That was exactly what I
needed. Truly appreciate your help. Cheers
Stan
 

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