<?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: Send Word document as email body	</title>
	<atom:link href="https://simpleexcelvba.com/send-word-document-as-email-body/feed/" rel="self" type="application/rss+xml" />
	<link>https://simpleexcelvba.com/send-word-document-as-email-body/</link>
	<description>Make your office life easier with simple and fast Excel VBA solutions.</description>
	<lastBuildDate>Wed, 06 Dec 2023 10:44:08 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		By: Tomasz Płociński		</title>
		<link>https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26775</link>

		<dc:creator><![CDATA[Tomasz Płociński]]></dc:creator>
		<pubDate>Wed, 06 Dec 2023 10:44:08 +0000</pubDate>
		<guid isPermaLink="false">https://simpleexcelvba.com/?p=1148#comment-26775</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26761&quot;&gt;David Aronson&lt;/a&gt;.

Wow, thank You for that, I will check that for sure!
Nowadays I changed my approach to prepare message template instead of Word template.
Much much easier and faster, maybe I&#039;ll do the article about that :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26761">David Aronson</a>.</p>
<p>Wow, thank You for that, I will check that for sure!<br />
Nowadays I changed my approach to prepare message template instead of Word template.<br />
Much much easier and faster, maybe I&#8217;ll do the article about that 🙂</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: David Aronson		</title>
		<link>https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26761</link>

		<dc:creator><![CDATA[David Aronson]]></dc:creator>
		<pubDate>Tue, 22 Aug 2023 20:22:55 +0000</pubDate>
		<guid isPermaLink="false">https://simpleexcelvba.com/?p=1148#comment-26761</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://simpleexcelvba.com/send-word-document-as-email-body/#comment-8732&quot;&gt;Tomasz Płociński&lt;/a&gt;.

Instead of using .display to get the paste to show up before doing .send, I think you can close the inspector with the save option and then do the .send, like this:
Set OutlookInspector = msgA.GetInspector
Set weA = msgA.GetInspector.WordEditor
weA.Content.Paste
OutlookInspector.Close 0 &#039; This saves the document
msgA.Send

This removes the flicker.  It worked for my tests (and yes, otherwise it needed .display)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://simpleexcelvba.com/send-word-document-as-email-body/#comment-8732">Tomasz Płociński</a>.</p>
<p>Instead of using .display to get the paste to show up before doing .send, I think you can close the inspector with the save option and then do the .send, like this:<br />
Set OutlookInspector = msgA.GetInspector<br />
Set weA = msgA.GetInspector.WordEditor<br />
weA.Content.Paste<br />
OutlookInspector.Close 0 &#8216; This saves the document<br />
msgA.Send</p>
<p>This removes the flicker.  It worked for my tests (and yes, otherwise it needed .display)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Piotr		</title>
		<link>https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26742</link>

		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Thu, 15 Jun 2023 08:42:17 +0000</pubDate>
		<guid isPermaLink="false">https://simpleexcelvba.com/?p=1148#comment-26742</guid>

					<description><![CDATA[Hi. Sorry for late reply :0 

I was able to complete my file using below code :

Sub Wysylanie_maili() 
Dim OutApp As Object 
Dim OutMail As Object 
Dim rng As Range 
Dim fso As Object 
Dim tempfile As String 
Dim bodytext As String 
Dim wdApp As Object 
Dim wdDoc As Object 
Dim tempdoc As String

Dim sh As Worksheet
Dim cell As Range
Dim FileCell As Range
Dim rng1 As Range


Set OutApp = CreateObject(&quot;Outlook.Application&quot;)
Set fso = CreateObject(&quot;Scripting.FileSystemObject&quot;)

Set sh = Sheets(&quot;Generowanie&quot;)
&#039; On Error Resume Next

&#039;loop
For Each rng In Range(&quot;A14&quot;, Range(&quot;A&quot; &#038; Rows.Count).End(xlUp))
    
    &#039;create mail
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
        .SentOnBehalfOfName = &quot;mail@mail.pl&quot;
        .To = rng.Offset(0, 2).Value
        .CC = rng.Offset(0, 3).Value
        .BCC = rng.Offset(0, 4).Value
        .Subject = rng.Offset(0, 9).Value
        
        &#039;add files
        If Not IsEmpty(rng.Offset(0, 10).Value) Then
            .Attachments.Add (rng.Offset(0, 10).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 11).Value) Then
            .Attachments.Add (rng.Offset(0, 11).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 12).Value) Then
            .Attachments.Add (rng.Offset(0, 12).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 13).Value) Then
            .Attachments.Add (rng.Offset(0, 13).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 14).Value) Then
            .Attachments.Add (rng.Offset(0, 14).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 15).Value) Then
            .Attachments.Add (rng.Offset(0, 15).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 16).Value) Then
            .Attachments.Add (rng.Offset(0, 16).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 17).Value) Then
            .Attachments.Add (rng.Offset(0, 17).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 18).Value) Then
            .Attachments.Add (rng.Offset(0, 18).Value)
        End If
        
        If Not IsEmpty(rng.Offset(0, 19).Value) Then
            .Attachments.Add (rng.Offset(0, 19).Value)
        End If
        
                    
        &#039;open word doc
        Set wdApp = CreateObject(&quot;Word.Application&quot;)
        tempdoc = rng.Offset(0, 8).Value
        Set wdDoc = wdApp.Documents.Open(tempdoc, ReadOnly:=True)
        
        &#039;copy and paste to mail
        wdDoc.Content.Copy
        .HTMLBody = &quot;&quot; &#038; .HTMLBody &#038; &quot;&quot;
        .GetInspector().WordEditor.Range.PasteAndFormat wdFormatOriginalFormatting
        
         With WordEditor.Range.Find
            .Text = &quot;Szanowni,&quot; &#039;&#060;-dears
            .Replacement.Text = (rng.Offset(0, 17).Value) &#039;&#060;- replace dears with column value , names
            .Wrap = 1
            .Forward = True
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
            .Execute Replace:=2
        End With
        
        &#039;close word and delete temp file
        wdDoc.Close SaveChanges:=False
        wdApp.Quit
        Set wdDoc = Nothing
        Set wdApp = Nothing
        DoEvents &#039;wait for word to close
        If fso.FileExists(tempfile) Then
            On Error Resume Next
            fso.DeleteFile tempfile
            On Error GoTo 0
        End If
        
       
        .Display
        
    End With
    
    &#039;Move to the next row of data
    Set OutMail = Nothing
    Set rng = rng.Offset(1, 0)
    
Next rng

&#039;Clean up
Set fso = Nothing
Set OutApp = Nothing
End Sub



I didn&#039;t know how to add variable amount of attachements , so I have max 7 of them as I will not need more.

Hope this comes handy to someone who may need it.

Much appreciate your answers. 
Kind regards 
Piotr]]></description>
			<content:encoded><![CDATA[<p>Hi. Sorry for late reply :0 </p>
<p>I was able to complete my file using below code :</p>
<p>Sub Wysylanie_maili()<br />
Dim OutApp As Object<br />
Dim OutMail As Object<br />
Dim rng As Range<br />
Dim fso As Object<br />
Dim tempfile As String<br />
Dim bodytext As String<br />
Dim wdApp As Object<br />
Dim wdDoc As Object<br />
Dim tempdoc As String</p>
<p>Dim sh As Worksheet<br />
Dim cell As Range<br />
Dim FileCell As Range<br />
Dim rng1 As Range</p>
<p>Set OutApp = CreateObject(&#8220;Outlook.Application&#8221;)<br />
Set fso = CreateObject(&#8220;Scripting.FileSystemObject&#8221;)</p>
<p>Set sh = Sheets(&#8220;Generowanie&#8221;)<br />
&#8216; On Error Resume Next</p>
<p>&#8216;loop<br />
For Each rng In Range(&#8220;A14&#8221;, Range(&#8220;A&#8221; &amp; Rows.Count).End(xlUp))</p>
<p>    &#8216;create mail<br />
    Set OutMail = OutApp.CreateItem(0)<br />
    With OutMail<br />
        .SentOnBehalfOfName = &#8220;mail@mail.pl&#8221;<br />
        .To = rng.Offset(0, 2).Value<br />
        .CC = rng.Offset(0, 3).Value<br />
        .BCC = rng.Offset(0, 4).Value<br />
        .Subject = rng.Offset(0, 9).Value</p>
<p>        &#8216;add files<br />
        If Not IsEmpty(rng.Offset(0, 10).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 10).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 11).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 11).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 12).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 12).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 13).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 13).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 14).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 14).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 15).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 15).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 16).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 16).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 17).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 17).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 18).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 18).Value)<br />
        End If</p>
<p>        If Not IsEmpty(rng.Offset(0, 19).Value) Then<br />
            .Attachments.Add (rng.Offset(0, 19).Value)<br />
        End If</p>
<p>        &#8216;open word doc<br />
        Set wdApp = CreateObject(&#8220;Word.Application&#8221;)<br />
        tempdoc = rng.Offset(0, 8).Value<br />
        Set wdDoc = wdApp.Documents.Open(tempdoc, ReadOnly:=True)</p>
<p>        &#8216;copy and paste to mail<br />
        wdDoc.Content.Copy<br />
        .HTMLBody = &#8220;&#8221; &amp; .HTMLBody &amp; &#8220;&#8221;<br />
        .GetInspector().WordEditor.Range.PasteAndFormat wdFormatOriginalFormatting</p>
<p>         With WordEditor.Range.Find<br />
            .Text = &#8220;Szanowni,&#8221; &#8216;&lt;-dears<br />
            .Replacement.Text = (rng.Offset(0, 17).Value) &#039;&lt;- replace dears with column value , names<br />
            .Wrap = 1<br />
            .Forward = True<br />
            .Format = False<br />
            .MatchCase = False<br />
            .MatchWholeWord = False<br />
            .MatchWildcards = False<br />
            .MatchSoundsLike = False<br />
            .MatchAllWordForms = False<br />
            .Execute Replace:=2<br />
        End With</p>
<p>        &#039;close word and delete temp file<br />
        wdDoc.Close SaveChanges:=False<br />
        wdApp.Quit<br />
        Set wdDoc = Nothing<br />
        Set wdApp = Nothing<br />
        DoEvents &#039;wait for word to close<br />
        If fso.FileExists(tempfile) Then<br />
            On Error Resume Next<br />
            fso.DeleteFile tempfile<br />
            On Error GoTo 0<br />
        End If</p>
<p>        .Display</p>
<p>    End With</p>
<p>    &#039;Move to the next row of data<br />
    Set OutMail = Nothing<br />
    Set rng = rng.Offset(1, 0)</p>
<p>Next rng</p>
<p>&#039;Clean up<br />
Set fso = Nothing<br />
Set OutApp = Nothing<br />
End Sub</p>
<p>I didn&#039;t know how to add variable amount of attachements , so I have max 7 of them as I will not need more.</p>
<p>Hope this comes handy to someone who may need it.</p>
<p>Much appreciate your answers.<br />
Kind regards<br />
Piotr</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Tomasz Płociński		</title>
		<link>https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26669</link>

		<dc:creator><![CDATA[Tomasz Płociński]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 13:03:05 +0000</pubDate>
		<guid isPermaLink="false">https://simpleexcelvba.com/?p=1148#comment-26669</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26668&quot;&gt;Piotr&lt;/a&gt;.

You did not set any value to &lt;strong&gt;lastRow&lt;/strong&gt;, so the loop does not even start
--&gt; so how You got a blank mail?
You create an email during loop AND once before for loop starts.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26668">Piotr</a>.</p>
<p>You did not set any value to <strong>lastRow</strong>, so the loop does not even start<br />
&#8211;> so how You got a blank mail?<br />
You create an email during loop AND once before for loop starts.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Piotr		</title>
		<link>https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26668</link>

		<dc:creator><![CDATA[Piotr]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 08:33:24 +0000</pubDate>
		<guid isPermaLink="false">https://simpleexcelvba.com/?p=1148#comment-26668</guid>

					<description><![CDATA[@Tomasz Płociński
There is no error message. 
Even after moving .Display it just stays blank and does not do anything.]]></description>
			<content:encoded><![CDATA[<p>@Tomasz Płociński<br />
There is no error message.<br />
Even after moving .Display it just stays blank and does not do anything.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Tomasz Płociński		</title>
		<link>https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26667</link>

		<dc:creator><![CDATA[Tomasz Płociński]]></dc:creator>
		<pubDate>Wed, 08 Mar 2023 07:14:04 +0000</pubDate>
		<guid isPermaLink="false">https://simpleexcelvba.com/?p=1148#comment-26667</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26666&quot;&gt;Piotr&lt;/a&gt;.

At the first glance looks fine.
What is the error?
Try to move &lt;strong&gt;.Display&lt;/strong&gt; just under the &lt;strong&gt;With OutMail&lt;/strong&gt;
And of course if You want to send it remember to add &lt;strong&gt;.Send&lt;/strong&gt; :)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://simpleexcelvba.com/send-word-document-as-email-body/#comment-26666">Piotr</a>.</p>
<p>At the first glance looks fine.<br />
What is the error?<br />
Try to move <strong>.Display</strong> just under the <strong>With OutMail</strong><br />
And of course if You want to send it remember to add <strong>.Send</strong> 🙂</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
