<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Automating Word</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 08 Feb 2012 23:58:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: thiago</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-36116</link>
		<dc:creator>thiago</dc:creator>
		<pubDate>Mon, 17 Nov 2008 14:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-36116</guid>
		<description>&lt;p&gt;it works (well) with words, but i need do replace some graphics from excel to word... i marked the graphics in word with &quot;bookmarks&quot; but i don&#039;t know the next step...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>it works (well) with words, but i need do replace some graphics from excel to word&#8230; i marked the graphics in word with &#8220;bookmarks&#8221; but i don&#8217;t know the next step&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aaron Love</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-31281</link>
		<dc:creator>Aaron Love</dc:creator>
		<pubDate>Thu, 13 Mar 2008 19:53:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-31281</guid>
		<description>&lt;p&gt;Love it. Over the years, I&#039;ve come to beleive that if my boss(es) could think of it, it could be coded. Inserting data from an Excel document to a Word document via VBA was a challenage. I knew that the Word bookmarks were the key. Could not have done it without you. Thanks!!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Love it. Over the years, I&#8217;ve come to beleive that if my boss(es) could think of it, it could be coded. Inserting data from an Excel document to a Word document via VBA was a challenage. I knew that the Word bookmarks were the key. Could not have done it without you. Thanks!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-26750</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Fri, 24 Aug 2007 13:21:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-26750</guid>
		<description>&lt;p&gt;There are occasional instances in which For Each doesn&#039;t work reliably in collections. I have read that &quot;For Each co In ActiveSheet.ChartObjects&quot; sometimes misses a chart, but I don&#039;t recall ever seeing it, and I&#039;ve done a few charts in my day. I do know I had problems with Word Bookmarks, and what I did was like this:&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Redim&lt;/span&gt; sBkmk(1 &lt;span class=&quot;kw1&quot;&gt;to&lt;/span&gt; .BookMarks.Count)&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; iBkmk = 1 &lt;span class=&quot;kw1&quot;&gt;to&lt;/span&gt; .BookMarks.Count&lt;br&gt;
&#160; sBkmk(iBkmk) = .BookMarks(iBkmk).Name&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;and then I called each bookmark by name when processing it (and probably debug.printing its name to help track it).&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>There are occasional instances in which For Each doesn&#8217;t work reliably in collections. I have read that &#8220;For Each co In ActiveSheet.ChartObjects&#8221; sometimes misses a chart, but I don&#8217;t recall ever seeing it, and I&#8217;ve done a few charts in my day. I do know I had problems with Word Bookmarks, and what I did was like this:</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Redim</span> sBkmk(1 <span class="kw1">to</span> .BookMarks.Count)<br />
<span class="kw1">For</span> iBkmk = 1 <span class="kw1">to</span> .BookMarks.Count<br />
&nbsp; sBkmk(iBkmk) = .BookMarks(iBkmk).Name<br />
<span class="kw1">Next</span></div>
</div>
<p>and then I called each bookmark by name when processing it (and probably debug.printing its name to help track it).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ollie</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-26732</link>
		<dc:creator>Ollie</dc:creator>
		<pubDate>Fri, 24 Aug 2007 00:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-26732</guid>
		<description>&lt;p&gt;I put the call to FillBookmark inside a For loop:&lt;/p&gt;
&lt;p&gt;FOR each bm in mainDoc.bookmarks&lt;br&gt;
...&lt;br&gt;
FillBookmark mainDoc, sName, &quot;bmWinner&quot;&lt;br&gt;
...&lt;br&gt;
next&lt;/p&gt;
&lt;p&gt;But, the bm never increments.  What is going on here with the doc reference...  How can I get the loop to work or why does it not go to the next bm?&lt;/p&gt;
&lt;p&gt;Ollie&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I put the call to FillBookmark inside a For loop:</p>
<p>FOR each bm in mainDoc.bookmarks<br />
&#8230;<br />
FillBookmark mainDoc, sName, &#8220;bmWinner&#8221;<br />
&#8230;<br />
next</p>
<p>But, the bm never increments.  What is going on here with the doc reference&#8230;  How can I get the loop to work or why does it not go to the next bm?</p>
<p>Ollie</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike "the dude"</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-10853</link>
		<dc:creator>Mike "the dude"</dc:creator>
		<pubDate>Tue, 12 Apr 2005 21:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-10853</guid>
		<description>&lt;p&gt;I know this is a few months later...&lt;br&gt;
In C# :&lt;/p&gt;
&lt;p&gt;object o1 = &quot;Text1?;&lt;/p&gt;
&lt;p&gt;Word.Application wordApp = new Word.ApplicationClass();&lt;br&gt;
object fileName = @&quot;C:yourfile.doc&quot;;&lt;br&gt;
object missing = Type.Missing; &lt;/p&gt;
&lt;p&gt;Word.Document dCurrentDoc = wordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing,&lt;br&gt;
 ref missing, ref missing, ref missing, ref missing,&lt;br&gt;
 ref missing, ref missing, ref missing,&lt;br&gt;
 ref isVisible);&lt;/p&gt;
&lt;p&gt;dCurrentDoc.Activate();&lt;/p&gt;
&lt;p&gt;string strg = wordApp.ActiveDocument.FormFields.Item(ref o1).Result;&lt;/p&gt;
&lt;p&gt;this will give you the contents of the FormField. Hint: make sure that the Document is Protected during addition of text to the FormFields otherwise the Formfield is deleted and only the text is left.&lt;/p&gt;
&lt;p&gt;Hope this helps someone...&lt;br&gt;
Mike&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I know this is a few months later&#8230;<br />
In C# :</p>
<p>object o1 = &#8220;Text1?;</p>
<p>Word.Application wordApp = new Word.ApplicationClass();<br />
object fileName = @&#8221;C:yourfile.doc&#8221;;<br />
object missing = Type.Missing; </p>
<p>Word.Document dCurrentDoc = wordApp.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing,<br />
 ref missing, ref missing, ref missing, ref missing,<br />
 ref missing, ref missing, ref missing,<br />
 ref isVisible);</p>
<p>dCurrentDoc.Activate();</p>
<p>string strg = wordApp.ActiveDocument.FormFields.Item(ref o1).Result;</p>
<p>this will give you the contents of the FormField. Hint: make sure that the Document is Protected during addition of text to the FormFields otherwise the Formfield is deleted and only the text is left.</p>
<p>Hope this helps someone&#8230;<br />
Mike</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joao Pereira</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-9718</link>
		<dc:creator>Joao Pereira</dc:creator>
		<pubDate>Mon, 28 Mar 2005 16:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-9718</guid>
		<description>&lt;p&gt;hi!!!&lt;/p&gt;
&lt;p&gt;anyone has this in c# ??&lt;/p&gt;
&lt;p&gt;best regards from portugal,&lt;br&gt;
Joao&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>hi!!!</p>
<p>anyone has this in c# ??</p>
<p>best regards from portugal,<br />
Joao</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Francis-Wright</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-6683</link>
		<dc:creator>Tim Francis-Wright</dc:creator>
		<pubDate>Wed, 02 Feb 2005 21:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-6683</guid>
		<description>&lt;p&gt;I know from experience that this technique works quite welluntil and unless users delete bookmarks.  And it&#039;s very easy for users to delete bookmarks in Word.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I know from experience that this technique works quite welluntil and unless users delete bookmarks.  And it&#8217;s very easy for users to delete bookmarks in Word.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-6682</link>
		<dc:creator>Dick</dc:creator>
		<pubDate>Wed, 02 Feb 2005 20:45:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-6682</guid>
		<description>&lt;p&gt;pwf: There is a sub and a function.  The function got screwed up when I migrated servers, but it&#039;s fixed now.  Make sure you copy the function to your project and it should work.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>pwf: There is a sub and a function.  The function got screwed up when I migrated servers, but it&#8217;s fixed now.  Make sure you copy the function to your project and it should work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Problems with FillBookmark</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-6671</link>
		<dc:creator>Problems with FillBookmark</dc:creator>
		<pubDate>Wed, 02 Feb 2005 14:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-6671</guid>
		<description>&lt;p&gt;Hello&lt;/p&gt;
&lt;p&gt;I tried to use this example, but the FillBookmark does not work.&lt;/p&gt;
&lt;p&gt;I get a error &quot;Sub or function not defined&quot;. Could you help me, what is wrong?&lt;/p&gt;
&lt;p&gt;Sub CreateWordDoc()&lt;/p&gt;
&lt;p&gt;    Dim wdApp As Object&lt;br&gt;
    Dim wdDoc As Object&lt;br&gt;
    Dim rCell As Range&lt;br&gt;
    Dim rRng As Range&lt;br&gt;
    Dim lScore As Long&lt;br&gt;
    Dim sName As String&lt;/p&gt;
&lt;p&gt;    Set rRng = Sheet1.Range(&quot;A2:A6?)&lt;br&gt;
    lScore = 100 &#039;set the max possible score&lt;/p&gt;
&lt;p&gt;    &#039;loop through the range&lt;br&gt;
    For Each rCell In rRng.Cells&lt;br&gt;
        &#039;if the score is less than previous&lt;br&gt;
        If rCell.Offset(0, 1).Value &lt; lScore Then&lt;br&gt;
            &#039;store the data as variables&lt;br&gt;
            lScore = rCell.Offset(0, 1).Value&lt;br&gt;
            sName = rCell.Value&lt;br&gt;
        End If&lt;br&gt;
    Next rCell&lt;/p&gt;
&lt;p&gt;    &#039;open the word documents&lt;br&gt;
    Set wdApp = CreateObject(&quot;Word.Application&quot;)&lt;br&gt;
    Set wdDoc = wdApp.Documents.Open(&quot;C:AutoWord.doc&quot;)&lt;/p&gt;
&lt;p&gt;    &#039;replace the bookmarks with the variables&lt;br&gt;
    FillBookmark wdDoc, sName, &quot;bmWinner&quot;&lt;br&gt;
    FillBookmark wdDoc, lScore, &quot;bmScore&quot;, &quot;0?&lt;/p&gt;
&lt;p&gt;    &#039;show the word document&lt;br&gt;
    wdApp.Visible = True&lt;/p&gt;
&lt;p&gt;End Sub&lt;/p&gt;
&lt;p&gt;Br. Jan&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hello</p>
<p>I tried to use this example, but the FillBookmark does not work.</p>
<p>I get a error &#8220;Sub or function not defined&#8221;. Could you help me, what is wrong?</p>
<p>Sub CreateWordDoc()</p>
<p>    Dim wdApp As Object<br />
    Dim wdDoc As Object<br />
    Dim rCell As Range<br />
    Dim rRng As Range<br />
    Dim lScore As Long<br />
    Dim sName As String</p>
<p>    Set rRng = Sheet1.Range(&#8220;A2:A6?)<br />
    lScore = 100 &#8216;set the max possible score</p>
<p>    &#8216;loop through the range<br />
    For Each rCell In rRng.Cells<br />
        &#8216;if the score is less than previous<br />
        If rCell.Offset(0, 1).Value &lt; lScore Then<br />
            &#8216;store the data as variables<br />
            lScore = rCell.Offset(0, 1).Value<br />
            sName = rCell.Value<br />
        End If<br />
    Next rCell</p>
<p>    &#8216;open the word documents<br />
    Set wdApp = CreateObject(&#8220;Word.Application&#8221;)<br />
    Set wdDoc = wdApp.Documents.Open(&#8220;C:AutoWord.doc&#8221;)</p>
<p>    &#8216;replace the bookmarks with the variables<br />
    FillBookmark wdDoc, sName, &#8220;bmWinner&#8221;<br />
    FillBookmark wdDoc, lScore, &#8220;bmScore&#8221;, &#8220;0?</p>
<p>    &#8216;show the word document<br />
    wdApp.Visible = True</p>
<p>End Sub</p>
<p>Br. Jan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dale Dunphy</title>
		<link>http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/#comment-2152</link>
		<dc:creator>Dale Dunphy</dc:creator>
		<pubDate>Fri, 03 Sep 2004 04:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=718#comment-2152</guid>
		<description>&lt;p&gt;The code seemed to run okay and changed the Word document. However, now I am getting a message that the document is read-only and do I want to create another copy.  &lt;/p&gt;
&lt;p&gt;Is there a bug somewhere that the document is not closed properly.  Now, I cannot delete or re-save over the Word document.&lt;/p&gt;
&lt;p&gt;Many thanks,&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>The code seemed to run okay and changed the Word document. However, now I am getting a message that the document is read-only and do I want to create another copy.  </p>
<p>Is there a bug somewhere that the document is not closed properly.  Now, I cannot delete or re-save over the Word document.</p>
<p>Many thanks,</p>
]]></content:encoded>
	</item>
</channel>
</rss>

