How to write data to MS Word bookmarks using JScript

D

darkstar

I really really hope someone can help with this one. I have a form
that I'm using to create a Word document using XSL transformations
with WordML. Plain and rich text are transformed OK, but no matter
what I do tables always seem to screw up. I'm now exploring a hybrid
solution, with XSL transforms for text and bookmarks to transfer data
in table cells. I have an old form with VBScript code to write to
table cells starting from a bookmark in the first cell:

Sub cmdWordDoc_OnClick(eventObj)

Set objWord = CreateObject("Word.Application")
objWord.Documents.Open("C:\Templates\Test_Template.dot")
objWord.Visible = True

With objWord.Selection
.GoTo -1,,,"TableCell1_Bookmark"
.TypeText XDocument.DOM.selectSingleNode("//
my:Row1_Column1").Text
.MoveRight 12
.TypeText XDocument.DOM.selectSingleNode("//
my:Row1_Column2").Text
.MoveRight 12
.TypeText XDocument.DOM.selectSingleNode("//
my:Row1_Column3").Text
<and so on... until the table is filled>
End With

End Sub

Unfortunately, my current form has code in JScript, and at this point
so much work has gone into it that I don't feel it's worth it to
convert the whole thing to VBScript. I have the first part working
and can open the Word template, but I can't seem to find the JScript
equivalents to work with the bookmarks.

On a related note, what would be the proper way to code a For-Each
type loop in JScript to transfer data from a repeating table in
InfoPath to the Word table described above? The source repeating
table in IP and the target table in Word would have the same number of
columns but the number of rows would only be known at runtime.

I'm using IP2007 but saving as IP2003 for compatibility.

Thanks in advance for any and all help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top