View Single Post
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] em_serg@tut.by is offline
external usenet poster
 
Posts: 1
Default XMLNodes in headers, footers, text boxes etc.

Hi,

I'm using XMLNodes in Word documents. There is a problem if some of
them are
placed in stories other then Main Text Story (i.e. in headers/footers,
text
boxes etc.). In this case reading XMLNodes properties causes an error
for just opened
documents. If XMLNodes where manually selected after document
opening,
reading its properties works fine. It is illustrated by the following
VBA
procedure and its output (XMLNodes are in main text, text box and
header):


Sub XMLNodesProperties()
On Error GoTo ErrorHandler

Dim myStoryRange As Range
Dim node As XMLNode
Dim i As Integer

i = 1
For Each myStoryRange In ThisDocument.StoryRanges
For Each node In myStoryRange.XMLNodes
Debug.Print "Node" & i & ": " & "StoryType = " &
myStoryRange.StoryType & ", "
Debug.Print "BaseName = " & node.BaseName & vbCrLf
i = i + 1
Next
Next myStoryRange
Exit Sub
ErrorHandler:
Debug.Print "Err = " & Err.Number & ", " & "Description = " &
Err.Description & vbCrLf
Resume Next
End Sub


Output for just opened document:
Node1: StoryType = 1,
BaseName = Test

Node2: StoryType = 5,
Err = -2147467259, Description = Method 'BaseName' of object 'XMLNode'
failed

Node3: StoryType = 7,
Err = -2147467259, Description = Method 'BaseName' of object 'XMLNode'
failed


Output after selecting each XMLNode manually:
Node1: StoryType = 1,
BaseName = Test

Node2: StoryType = 5,
BaseName = Test

Node3: StoryType = 7,
BaseName = Test


Is there a way to read XMLNode properties without selecting them all?

Best regards,
Sergei