<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>How to write data to MS Word bookmarks using JScript</title><link>https://www.infopathdev.com:443/forums/thread/47683.aspx</link><pubDate>Wed, 07 Oct 2009 19:34:04 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:47683</guid><dc:creator>darkstar</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/47683.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=47683</wfw:commentRss><description>&lt;p&gt;I really really hope someone can help with this one.&amp;nbsp; I have a form that I&amp;#39;m using to create a Word document using XSL transformations with WordML.&amp;nbsp; Plain and rich text are transformed OK, but no matter what I do tables always seem to screw up.&amp;nbsp; I&amp;#39;m now exploring a hybrid solution, with XSL transforms for text and bookmarks to transfer data in table cells.&amp;nbsp; I have an old form with VBScript code to write to table cells starting from a bookmark in the first cell:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Sub cmdWordDoc_OnClick(eventObj)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; Set objWord = CreateObject(&amp;quot;Word.Application&amp;quot;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; objWord.Documents.Open(&amp;quot;C:\Templates\Test_Template.dot&amp;quot;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; objWord.Visible = True&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; With objWord.Selection
&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .GoTo -1,,,&amp;quot;TableCell1_Bookmark&amp;quot;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .TypeText&amp;nbsp; XDocument.DOM.selectSingleNode(&amp;quot;//my:Row1_Column1&amp;quot;).Text&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .MoveRight 12&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .TypeText&amp;nbsp; XDocument.DOM.selectSingleNode(&amp;quot;//my:Row1_Column2&amp;quot;).Text&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .MoveRight 12&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; .TypeText&amp;nbsp; XDocument.DOM.selectSingleNode(&amp;quot;//my:Row1_Column3&amp;quot;).Text&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;and so on... until the table is filled&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp; End With&lt;/p&gt;&lt;p&gt;End Sub&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Unfortunately, my current form has code in JScript, and at this point so much work has gone into it that I don&amp;#39;t feel it&amp;#39;s worth it to convert the whole thing to VBScript.&amp;nbsp; I have the first part working and can open the Word template, but I can&amp;#39;t seem to find the JScript equivalents to work with the bookmarks.&lt;/p&gt;&lt;p&gt;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?&amp;nbsp; 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.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I&amp;#39;m using IP2007 but saving as IP2003 for compatibility.&lt;/p&gt;&lt;p&gt;Thanks in advance for any and all help! &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>