Skip to content

Nasri Messarra

Associate Professor, Senior Expert in Digital Communication

Menu
  • Home
  • Social Media
  • Office and Web tools
  • Multimedia
  • USJ
  • About Me
Menu

Outlook VBA code for HTML newsletter

Posted on January 18, 2014May 6, 2023 by N.A.M.

This is an MS Outlook 2013 code to insert an HTML file into an email. File can have CSS definitions and external links to photos.

1- Go to file -> Options.2- In the “Customize Ribbon” section, check “Developer” in the Customize the Ribbon / Main Tabs panel (right) – Click OK
3- Open the Developer tab in the Ribbon. Click on Macros, Macros, Type “InsertHTML” and Create
4- In the Microsoft VBA window, click on tools -> References and make sure Microsoft Office 15.0 Object Library and Microsoft Word 15.0 Object Library are both checked- press OK
5- Copy and paste the following code:

Sub InsertHTML()
Dim insp As Inspector
Set insp = ActiveInspector
If insp.IsWordMail Then
Dim wordDoc As Word.Document
Set wordDoc = insp.WordEditor
Dim FileToOpen As String
FileToOpen = InputBox(“filename?”)
wordDoc.Application.Selection.InsertFile FileToOpen, , False, False, False
End If
End Sub

6- Save and close the Microsoft VBA editor
7- In the main menu, click on the developer tab in the ribbon, click on “Macro Security”. Select “Notification for all Macros”.8- Open a new message. Place the cursor in the empty message, go to Developer, click on Macro and select the Project1.InsertHTML macro.
9- When prompted enter the HTML file to import location.

 

Leave a Reply Cancel reply

You must be logged in to post a comment.

Nasri Messarra
View this post on Instagram

A post shared by Nasri Messarra | Photography (@nasri.messarra)

© 2023 Nasri Messarra | Powered by Superbs Personal Blog theme