![]() |
|
#1
|
|||
|
|||
|
I'm trying to create a namespace in athe Custom XML part of a Word document.
I've done extensive googling but good documentation is thin to non-existent. The following code is extracted from Microsoft's help pages on CustomXMLPrefixMappings Code:
Sub addXMLNamespaceTest()
' https://msdn.microsoft.com/en-us/library/office/ff863518.aspx
Dim objNamespace As CustomXMLPrefixMapping
objNamespace = CustomXMLPrefixMappings.AddNamespace(Prefix:="xs", NamespaceURI:="urn:invoice:namespace")
End Sub
A similar example found under the 'addnamespace' help (You have to add the XML to the CustomXMLPrefixMappings https://msdn.microsoft.com/en-us/lib...ffice.15).aspx Code:
Sub AddNamespacePrefix()
Dim objCustomPrefixMappings As CustomXMLPrefixMappings
Dim varCustomMapping As Variant
' Adds a custom namespace.
varCustomMapping = objCustomPrefixMappings.AddNamespace("xs", "urn:invoice:namespace")
End Sub
Can anyone assist with the correct syntax for adding a namespace. If it helps I've tried the code below (with reference to https://www.w3schools.com/xml/xml_namespaces.asp ) and the xml parts are added under (no namespace) (1) and (no namespace (2) hence the investigation of .addNamsespace. Code:
Sub testxmladd()
ActiveDocument.CustomXMLParts.add XML:= _
"<RCDP xmlns:a=""https://www.w3schools.com/furniture"">" & _
"<a:arcprop id=""HeadingVisibilityP"">" & _
"<a:visibility>True</a:visibility>" & _
"<a:enabled>True</a:enabled>" & _
"</a:arcprop>" & _
"<a:arcprop id= ""HeadingVisibilityS"">" & _
"<a:visibility>False</a:visibility>" & _
"<a:checked>True></a:checked>" & _
"</a:arcprop>" & _
"</RCDP>"
ActiveDocument.CustomXMLParts.add XML:= _
"<RCDP xmlns:a=""https://www.w3schools.com/furniture"">" & _
"<a:arcprop id=""HeadingVisibilityA"">" & _
"<a:visibility>True</a:visibility>" & _
"<a:enabled>True</a:enabled>" & _
"</a:arcprop>" & _
"<a:arcprop id= ""HeadingVisibilityR"">" & _
"<a:visibility>False</a:visibility>" & _
"<a:checked>True></a:checked>" & _
"</a:arcprop>" & _
"</RCDP>"
End Sub
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem batch adding autotext using Greg Maxey's Building Blocks Add-In | Genuine Gin | Word VBA | 5 | 12-16-2015 10:20 AM |
| Problem Sending Command to the Program - Office or Windows Problem ?? | JosieNurse | Office | 0 | 04-21-2015 11:49 AM |
Problem with Resolution when adding a picture in 2010
|
Zimm | PowerPoint | 1 | 11-13-2013 12:15 PM |
Problem with adding a footnote in Word
|
Swarles_Barkley | Word | 1 | 11-12-2013 11:42 PM |
Adding Image into a excel cell and adding a hyperlink to the image
|
saravananiyyanar | Excel | 3 | 05-04-2011 08:31 AM |