Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 06-08-2017, 03:37 AM
gmaxey gmaxey is offline Problem adding a namespace for customxml Windows 7 32bit Problem adding a namespace for customxml Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

What you are seeing is normal and to be expected. Consider this:

Code:
Sub testxmladd()
Dim i As Long
  For i = ActiveDocument.CustomXMLParts.Count To 4 Step -1
     ActiveDocument.CustomXMLParts(i).Delete
  Next
  'Add a part with Prefixed namespace:
  ActiveDocument.CustomXMLParts.Add XML:= _
        "<RCDP xmlns:a=""AAAAA"">" & _
        "<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>"
  'Add a part with default namespace (not prefixed).
  ActiveDocument.CustomXMLParts.Add XML:= _
        "<RCDP xmlns=""BBBBBBB"">" & _
        "<arcprop id=""HeadingVisibilityA"">" & _
        "<visibility>True</visibility>" & _
        "<enabled>True</enabled>" & _
        "</arcprop>" & _
        "<arcprop id= ""HeadingVisibilityR"">" & _
        "<visibility>False</visibility>" & _
        "<checked>True></checked>" & _
        "</arcprop>" & _
        "</RCDP>"
   ActiveDocument.CustomXMLParts.Add XML:= _
        "<RCDP xmlns=""CCCCCCCC"" xmlns:a=""DDDDDDDDD"">" & _
        "<arcprop id=""HeadingVisibilityA"">" & _
        "<visibility>True</visibility>" & _
        "<enabled>True</enabled>" & _
        "</arcprop>" & _
        "<arcprop id= ""HeadingVisibilityR"">" & _
        "<visibility>False</visibility>" & _
        "<checked>True></checked>" & _
        "</arcprop>" & _
        "</RCDP>"
  MsgBox ActiveDocument.CustomXMLParts(4).NamespaceURI 'Returns and empty string because there is no default namespace associted with the part.
  MsgBox ActiveDocument.CustomXMLParts(5).NamespaceURI
  MsgBox ActiveDocument.CustomXMLParts(6).NamespaceURI
  MsgBox ActiveDocument.CustomXMLParts(4).NamespaceManager.Item(1).NamespaceURI
  MsgBox ActiveDocument.CustomXMLParts(5).NamespaceManager.Item(1).NamespaceURI
  MsgBox ActiveDocument.CustomXMLParts(6).NamespaceManager.Item(1).NamespaceURI
  MsgBox ActiveDocument.CustomXMLParts(6).NamespaceManager.Item(2).NamespaceURI
  
  Dim oCPM  As CustomXMLPrefixMappings
  Set oCPM = ActiveDocument.CustomXMLParts(6).NamespaceManager
  oCPM.AddNamespace "xs", "EEEEEEEEEE"
  For i = 1 To oCPM.Count
    MsgBox oCPM.Item(i).Prefix & " " & oCPM.Item(i).NamespaceURI
  Next i
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



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 adding a namespace for customxml Problem with Resolution when adding a picture in 2010 Zimm PowerPoint 1 11-13-2013 12:15 PM
Problem adding a namespace for customxml Problem with adding a footnote in Word Swarles_Barkley Word 1 11-12-2013 11:42 PM
Problem adding a namespace for customxml Adding Image into a excel cell and adding a hyperlink to the image saravananiyyanar Excel 3 05-04-2011 08:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft