F
Frank Rice
I open a Word doc based on a template. In
the template I have attached a schema and added some elements to the doc,
one of which is called "FirstName.". What I am trying to do is set the value
of the FirstName element to some text. I have tried several techniques such
as
dim wdApp as New Word.Application
dim wdDoc as New Word.Document
dim wdTemp = "C:\MyTemplate.dot"
dim wdNode as Word.XMLNode
wdDoc = wdApp.Documents.Add(wdTemp)
wdNode = wdDoc.SelectSingleNode("/FirstName")
wdNode.Text = "Nancy"
when I do this, I get error msg 'object reference not set to an instance of
an object" telling me that '/FirstName" is not a valid XPath, I think. I
then try
wdNode = wdDoc.SelectSingleNode("FirstName")
wdNode = "Nancy"
and get the same error.
My question is how can I set the value of an XML element in a doc to a text
value at run time? Thanks for your help
the template I have attached a schema and added some elements to the doc,
one of which is called "FirstName.". What I am trying to do is set the value
of the FirstName element to some text. I have tried several techniques such
as
dim wdApp as New Word.Application
dim wdDoc as New Word.Document
dim wdTemp = "C:\MyTemplate.dot"
dim wdNode as Word.XMLNode
wdDoc = wdApp.Documents.Add(wdTemp)
wdNode = wdDoc.SelectSingleNode("/FirstName")
wdNode.Text = "Nancy"
when I do this, I get error msg 'object reference not set to an instance of
an object" telling me that '/FirstName" is not a valid XPath, I think. I
then try
wdNode = wdDoc.SelectSingleNode("FirstName")
wdNode = "Nancy"
and get the same error.
My question is how can I set the value of an XML element in a doc to a text
value at run time? Thanks for your help