Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2012, 02:52 PM
gmaxey gmaxey is offline CustomXMLParts.SelectByNamespace Windows 7 32bit CustomXMLParts.SelectByNamespace Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Probably better is to use SelectbyID:

PHP Code:
Sub DemoXX()
Dim oDoc As Word.Document
Dim oCustXMLPart As Office.CustomXMLPart
  Set oDoc = ActiveDocument
  'Kill any existing XMLPart used previously for demo.


  On Error Resume Next
    oDoc.CustomXMLParts.SelectByID(ActiveDocument.Variables("Part_ID")).Delete
  On Error GoTo 0
  'Create a basic XML Part with namespace.
  Set oCustXMLPart = ActiveDocument.CustomXMLParts.Add("<?xml version='1.0' ?><data xmlns='comments' xmlns:a='applicant'><a:Applicant><a:FullName>AEP Texas Central Company</a:FullName><a:AbbrName></a:AbbrName><a:DateFiled></a:DateFiled><a:Description></a:Description></a:Applicant></data>")
  'Store the ID value
  ActiveDocument.Variables("Part_ID").Value = oCustXMLPart.ID
  Set oCustXMLPart = Nothing
  RetrieveNodeData
End Sub
Sub RetrieveNodeData()
Dim oCustomXMLPart As CustomXMLPart
Dim oNode As CustomXMLNode
  Set oCustomXMLPart = ActiveDocument.CustomXMLParts.SelectByID(ActiveDocument.Variables("Part_ID"))
  'Or
  'Set oCustomXMLPart = ActiveDocument.CustomXMLParts.SelectByNamespace("comments").Item(1)
  Set oNode = oCustomXMLPart.SelectSingleNode("ns0:data[1]/ns1:Applicant[1]/ns1:FullName[1]")
  MsgBox oNode.Text
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Other Forums: Access Forums

All times are GMT -7. The time now is 08:29 AM.


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