<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Dansk Regneark Forum : VBA email vedhæftet email</title>
  <link>https://forum.excel-regneark.dk/</link>
  <description><![CDATA[Dette er et XML Feed af; Dansk Regneark Forum : Makro og VBA : VBA email vedhæftet email]]></description>
  <pubDate>Sat, 05 Dec 2026 15:34:18 +0000</pubDate>
  <lastBuildDate>Mon, 05 Feb 2018 18:11:33 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.08</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>https://forum.excel-regneark.dk/RSS_post_feed.asp?TID=3355</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Dansk Regneark Forum]]></title>
   <url>https://forum.excel-regneark.dk/css_styles/Excel-regneark.dk/logo.png</url>
   <link>https://forum.excel-regneark.dk/</link>
  </image>
  <item>
   <title><![CDATA[VBA email vedhæftet email : Denne lille kode skulle kunne...]]></title>
   <link>https://forum.excel-regneark.dk/vba-email-vedhftet-email_topic3355_post16570.html#16570</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=1125">Ib Hansen</a><br /><strong>Emne:</strong> 3355<br /><strong>Sendt:</strong> 05.Feb.2018 kl. 18:11<br /><br />Denne lille kode skulle kunne vedhæfte arket i en Office Outlook mail.<div>Kopier og indsæt koden ind i en Command Button&nbsp;<img src="https://forum.excel-regneark.dk/smileys/smiley2.gif" border="0" alt="Wink" title="Wink" /><br><table width="99%"><tr><td><pre class="BBcode"><b><font color="#009900">'-----------------------------------------'</font></b><div><b><font color="#009900">' Tjekker først om Outlook er installeret '</font></b></div><div><b><font color="#009900">' Hvis ikke kommer der MsgBox advarsel&nbsp; &nbsp; '</font></b></div><div><b><font color="#009900">'-----------------------------------------'</font></b></div><div>&nbsp; &nbsp; Dim OutApp As Object</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; On Error Resume Next&nbsp; &nbsp; <font color="#009900"><b>'Suspenderer error checking</b></font></div><div>&nbsp; &nbsp; &nbsp; &nbsp; Set OutApp = CreateObject("Outlook.Application")</div><div>&nbsp; &nbsp; On Error GoTo 0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<b><font color="#009900">'Gentager error checking</font></b></div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; If OutApp Is Nothing Then</div><div>&nbsp; &nbsp; MsgBox "&nbsp; &nbsp;Office Outlook er ikke installeret." _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &amp; vbNewLine &amp; vbNewLine &amp; "&nbsp; &nbsp;Gem og luk arket og send det med din normale mail." _</div><div>&nbsp; &nbsp; &nbsp; &nbsp; , vbInformation, "Outlook er ikke installeret"</div><div>&nbsp; &nbsp; &nbsp; &nbsp; Exit Sub</div><div>&nbsp; &nbsp; End If</div><div>&nbsp; &nbsp;&nbsp;</div><div><b><font color="#009900">'--------------------------'</font></b></div><div><b><font color="#009900">' Vedhæfter arket i mailen '</font></b></div><div><b><font color="#009900">'--------------------------'</font></b></div><div>&nbsp; &nbsp; Dim OutMail As Object</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; On Error GoTo ud</div><div>&nbsp; &nbsp; Set OutApp = CreateObject("Outlook.Application")</div><div>&nbsp; &nbsp; Set OutMail = OutApp.CreateItem(0)</div><div>&nbsp; &nbsp;&nbsp;</div><div><b><font color="#009900">'-----------------------------------------------'</font></b></div><div><b><font color="#009900">' Udfylder Til, Cc, Emne osv.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'</font></b></div><div><b><font color="#009900">' Hvis en linje er udkommanderet udfyldes intet '</font></b></div><div><b><font color="#009900">'-----------------------------------------------'</font></b></div><div>&nbsp; &nbsp; On Error Resume Next</div><div>&nbsp; &nbsp; With OutMail</div><div>&nbsp; &nbsp; &nbsp; &nbsp; <font color="#009900"><b>'.to = "Skriv mail adresse her"</b></font></div><div><font color="#009900"><b>&nbsp; &nbsp; &nbsp; &nbsp; '.CC = "</b><b style="">Skriv mail adresse her</b><b style="">"</b></font></div><div><font color="#009900"><b>&nbsp; &nbsp; &nbsp; &nbsp; '.BCC = "</b><b style="">Skriv mail adresse her</b><b style="">"</b></font></div><div><font color="#009900"><b>&nbsp; &nbsp; &nbsp; &nbsp; '.Subject = "</b><b style="">Skriv emnelinje her</b><b style="">"</b></font></div><div><font color="#009900"><b>&nbsp; &nbsp; &nbsp; &nbsp; '.Body = "Skriv evt. besked her"</b></font></div><div>&nbsp; &nbsp; &nbsp; &nbsp; .Attachments.Add ActiveWorkbook.FullName</div><div><b><font color="#009900">'-----------------------------------------------------------------'</font></b></div><div><b><font color="#009900">' Der kan tilføjes andre filer også, hvis stien til filen skrives '</font></b></div><div><b><font color="#009900">'-----------------------------------------------------------------'</font></b></div><div>&nbsp; &nbsp; &nbsp; &nbsp; <b><font color="#009900">'.Attachments.Add ("C:\test.txt")</font></b></div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div><b><font color="#009900">'----------------------------------------------------------------'</font></b></div><div><b><font color="#009900">' Her vælges om mailen skal sendes direkte eller åbnes i Outlook '</font></b></div><div><b><font color="#009900">'----------------------------------------------------------------'</font></b></div><div>&nbsp; &nbsp; &nbsp; &nbsp; .display ' Åbner mailen</div><div>&nbsp; &nbsp; &nbsp; &nbsp; <b><font color="#009900">'.Send&nbsp; &nbsp;' Sender mailen</font></b></div><div>&nbsp; &nbsp; End With</div><div>&nbsp; &nbsp; On Error GoTo 0</div><div><br></div><div><div><b><font color="#009900">'-----------------'</font></b></div><div><b><font color="#009900">' Nulstiller igen '</font></b></div><div><b><font color="#009900">'-----------------'</font></b></div></div><div>&nbsp; &nbsp; Set OutMail = Nothing</div><div>&nbsp; &nbsp; Set OutApp = Nothing</div>ud:</pre></td></tr></table></div>]]>
   </description>
   <pubDate>Mon, 05 Feb 2018 18:11:33 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/vba-email-vedhftet-email_topic3355_post16570.html#16570</guid>
  </item> 
  <item>
   <title><![CDATA[VBA email vedhæftet email : Hej Kloge mennesker :)F&#248;rst s&#229;...]]></title>
   <link>https://forum.excel-regneark.dk/vba-email-vedhftet-email_topic3355_post16569.html#16569</link>
   <description>
    <![CDATA[<strong>Forfatter:</strong> <a href="https://forum.excel-regneark.dk/member_profile.asp?PF=2157">Andersen25</a><br /><strong>Emne:</strong> 3355<br /><strong>Sendt:</strong> 05.Feb.2018 kl. 17:33<br /><br />Hej Kloge mennesker :)<div><br></div><div>Først så er jeg ordblind, så er jeg svær at forstå endelige spørg.</div><div><br></div><div>Jeg forsøger at lave en VBA/macro, der gør jeg kan vedhæfte excel filen i mail sendt fra excel.</div><div>Jeg har flere VBA knapper, som alle sender mail til forskellige personer. Min udforinger er at jeg kun i nogle af dem, har behov for at vedhæfte excel arket.</div><div><br></div><div>Det kan jeg dog ikke få til at virke.</div><div><br></div><div>Jeg har følgende module</div><div><div><br></div><div>Public Function sendMail(ByVal recipient, ByVal subject, Optional ByVal body As String, Optional ByVal Attachments = "")</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; Dim OutlookApp As Object</div><div>&nbsp; &nbsp; Dim NewMail As Object</div><div>&nbsp; &nbsp; Dim TempFilePath As String</div><div>&nbsp; &nbsp; Dim FileExt As String</div><div>&nbsp; &nbsp; Dim TempFileName As String</div><div>&nbsp; &nbsp; Dim FullFilePath As String</div><div>&nbsp; &nbsp; Dim Workbook As Workbook</div><div>&nbsp;&nbsp;</div><div>&nbsp;&nbsp;</div><div>&nbsp; &nbsp; Set Workbook = ThisWorkbook</div><div>&nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; With Application</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .ScreenUpdating = False</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .EnableEvents = False</div><div>&nbsp; &nbsp; End With</div><div>&nbsp; &nbsp; &nbsp;&nbsp;</div><div><br></div><div>&nbsp; &nbsp; ' Gem temp fil</div><div>&nbsp; &nbsp; TempFilePath = Environ$("temp") &amp; "\"</div><div>&nbsp; &nbsp; FileExt = "." &amp; LCase(Right(Workbook.Name, Len(Workbook.Name) - InStrRev(Workbook.Name, ".", , 1)))</div><div>&nbsp; &nbsp; TempFileName = Workbook.Name '&amp; "-" &amp; Format(Now, "dd-mmm-yy h-mm-ss")</div><div>&nbsp; &nbsp; FullFilePath = TempFilePath &amp; TempFileName ' &amp; FileExt</div><div><br></div><div>&nbsp; &nbsp; Workbook.SaveCopyAs FullFilePath</div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; ' Åben ny mail</div><div>&nbsp; &nbsp; Set OutlookApp = CreateObject("Outlook.Application")</div><div>&nbsp; &nbsp; Set NewMail = OutlookApp.CreateItem(0)</div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; On Error Resume Next</div><div>&nbsp; &nbsp; With NewMail</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .To = recipient</div><div>&nbsp; &nbsp; &nbsp; &nbsp; '.CC = cc</div><div>&nbsp; &nbsp; &nbsp; &nbsp; '.BCC = bcc</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .subject = subject</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .body = body</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .Attachments = Attachments</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .Display</div><div>&nbsp; &nbsp; End With</div><div>&nbsp; &nbsp; On Error GoTo 0</div><div>&nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; ' Mail sendt, slet temp fil og reset properties</div><div>&nbsp; &nbsp; Kill FullFilePath</div><div>&nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; Set NewMail = Nothing</div><div>&nbsp; &nbsp; Set OutlookApp = Nothing</div><div>&nbsp;</div><div>&nbsp; &nbsp; With Application</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .ScreenUpdating = True</div><div>&nbsp; &nbsp; &nbsp; &nbsp; .EnableEvents = True</div><div>&nbsp; &nbsp; End With</div><div>&nbsp; &nbsp;&nbsp;</div><div>End Function</div></div><div><br></div><div>Jeg forsøger mig så med følgen private Sub</div><div><br></div><div><div>Private Sub velkommen_Click()</div><div>&nbsp; &nbsp; Module1.sendMail "jesper.andersen@dk.loomis.com", ("Velkommen til Loomis - vi glæder os til at betjene dig"), "test", ("add. FullFilePath")</div><div>&nbsp; &nbsp; Cells(2, 18) = Now</div><div>&nbsp; End Sub</div></div><div><br></div><div>Min fejl ligger nok i måde jeg bruger private Sub Add. fullfilePath</div><div><br></div><div>På forhånd mange tak for jeres hjælp :)</div><div>Jesper Andersen</div>]]>
   </description>
   <pubDate>Mon, 05 Feb 2018 17:33:06 +0000</pubDate>
   <guid isPermaLink="true">https://forum.excel-regneark.dk/vba-email-vedhftet-email_topic3355_post16569.html#16569</guid>
  </item> 
 </channel>
</rss>