ActiveDocuments.CustomXMLParts.Add --> says that the file is loade

M

mparker1113

I am running the VBA code below. The initial run, everything seems to be
fine, but after that i had to add an On Error Resume Next statement, because
the error that "this custom xml part has already been loaded" was crashing
me. After i changed the value in the xml file i noticed that the
ActiveDocument.CustomXMLParts wasn't reloading the xml data.

Does anyone know how i can get this to reload the xml document with each
time that the document is open? (much thanks for input).

Sub OnLoad()

On Error Resume Next
ActiveDocument.CustomXMLParts.Add
ActiveDocument.CustomXMLParts(4).Load
("http://nrbsharepoint/Docs/Documents/CustomerData.xml")
On Error Resume Next

Dim strXPath1 As String
strXPath1 = "/Customer/CompanyName"
ActiveDocument.ContentControls(1).XMLMapping.SetMapping strXPath1

Dim strXPath2 As String
strXPath2 = "/Customer/ContactName"
ActiveDocument.ContentControls(2).XMLMapping.SetMapping strXPath2

Dim strXPath3 As String
strXPath3 = "/Customer/ContactTitle"
ActiveDocument.ContentControls(3).XMLMapping.SetMapping strXPath3

Dim strXPath4 As String
strXPath4 = "/Customer/Phone"
ActiveDocument.ContentControls(4).XMLMapping.SetMapping strXPath4

End Sub
 

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