You cannot insert more than one line of text into a protected XML node by using VBA in Word 2003 (827734)
The information in this article applies to:
- Microsoft Office Word 2003
SYMPTOMSIn Microsoft Office Word 2003, you cannot insert more then
one line of text into a protected XML node by using Microsoft Visual Basic for
Applications (VBA) code.WORKAROUNDTo work around this issue, add each line of text to the XML
node one line at a time. You must be careful where the insertion point is when
you add content to the XML node so that you do not replace existing
content. Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. The following macro provides one possible approach.
It inserts the word "Test" followed by two paragraph marks, followed by the
word "Test" in the third XML node in the document: Sub test()
ActiveDocument.XMLNodes(3).Range.Select
ActiveDocument.XMLNodes(3).Text = "Test"
ActiveDocument.XMLNodes(3).Range.Select
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertAfter vbCrLf
Selection.Collapse Direction:=wdCollapseEnd
Selection.MoveEnd Unit:=wdCharacter, Count:=-1
Selection.InsertAfter vbCrLf
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertAfter "Test"
End Sub
Modification Type: | Minor | Last Reviewed: | 7/27/2006 |
---|
Keywords: | kbXML kbprb KB827734 kbAudEndUser |
---|
|