• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Save Messages as *.DOC or *.DOCX File Type

Slipstick Systems

› Developer › Save Messages as *.DOC or *.DOCX File Type

Last reviewed on October 5, 2020     32 Comments

An Outlook user wanted to save all of his messages to his hard drive in *.doc format, so that the messages would be in a universal format and the attachments would stay with the document. While you can do this in Outlook, it takes several steps: you need to open the message, go into Edit mode, change the message format to Rich Text (RTF) and save it. Then use SaveAs to save the message to the hard drive.

Using VBA speeds the process up quite a bit.

To save attachments to your hard drive then open them: Save and Open an Attachment using VBA. To save attachments and remove them from the message, see Save and Delete Attachments from Outlook messages

The code adds the message date and time stamp to the filename, to avoid problems if multiple messages have the same subject. You could also add the sender's name to the filename, if desired. The date and time stamp code was taken from E-Mail: Save new items immediately as files.

Save selected messages as docx file type

This new version of the SaveSelectedAsDoc macro saves the selected messages as the docx file type. The other macros on the page use Outlook's supported file type of .doc.

Because Outlook doesn't have built in support to save a message as a docx file, you must set the reference to the Word Object Model in the VB Editor's Tools, References dialog and use Word to save the message.

Sub SaveSelectedAsDocX()
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim Item As Object
Dim dtDate As Date
Dim sName As String

Dim objInsp As Outlook.Inspector
Dim objWord As Word.Application
Dim objDoc As Word.Document

Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection

For Each Item In Selection
Set objInsp = Item.GetInspector
Set objDoc = objInsp.WordEditor
Set objWord = objDoc.Application

sName = Item.Subject
ReplaceCharsForFileName sName, "_"

dtDate = Item.ReceivedTime
  sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName
       

 objDoc.SaveAs2 Filename:="D:\Email\" & sName & ".docx", FileFormat:= _
        wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles _
        :=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _
        :=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
        SaveAsAOCELetter:=False, CompatibilityMode:=15
Next Item

End Sub

Private Sub ReplaceCharsForFileName(sName As String, sChr As String)
  sName = Replace(sName, "/", sChr)
  sName = Replace(sName, "\", sChr)
  sName = Replace(sName, ":", sChr)
  sName = Replace(sName, "?", sChr)
  sName = Replace(sName, Chr(34), sChr)
  sName = Replace(sName, "<", sChr)
  sName = Replace(sName, ">", sChr)
  sName = Replace(sName, "|", sChr)
  sName = Replace(sName, "&", sChr)
  sName = Replace(sName, "%", sChr)
  sName = Replace(sName, "*", sChr)
  sName = Replace(sName, " ", sChr)
  sName = Replace(sName, "{", sChr)
  sName = Replace(sName, "[", sChr)
  sName = Replace(sName, "]", sChr)
  sName = Replace(sName, "}", sChr)
End Sub

Save as Doc Macro

If the folder you want to save the documents to does not exist, create it before running the macro.

To use this code, open the VBA editor using Alt+F11 and paste this code into ThisOutlookSession. Change the path where the documents will be saved. Select a folder and run the macro. All messages within the folder will be saved as a Word document file.

A version of the macro that saves to a folder matching the folder name of the message (but not the full path, sorry) and stored under Documents, is available here.

Sub SaveAsDoc()

Dim myolApp As Outlook.Application
Dim Item As Object

Dim dtDate As Date
Dim sName As String

Set myolApp = CreateObject("Outlook.Application")
Set mail = myolApp.ActiveExplorer.CurrentFolder

For Each Item In mail.Items
    Item.BodyFormat = olFormatRichText

'If you want to convert all messages to RTF, uncomment this line. 
'Otherwise, the message format is not changed. 
   ' Item.Save

sName = Item.Subject
ReplaceCharsForFileName sName, "_"

dtDate = Item.ReceivedTime
  sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName

Item.SaveAs "C:\email\" & sName & ".doc", olDoc 

Next Item

End Sub

Private Sub ReplaceCharsForFileName(sName As String, sChr As String )
  sName = Replace(sName, "/", sChr)
  sName = Replace(sName, "\", sChr)
  sName = Replace(sName, ":", sChr)
  sName = Replace(sName, "?", sChr)
  sName = Replace(sName, Chr(34), sChr)
  sName = Replace(sName, "<", sChr)
  sName = Replace(sName, ">", sChr)
  sName = Replace(sName, "|", sChr)
  sName = Replace(sName, "&", sChr)
  sName = Replace(sName, "%", sChr)
  sName = Replace(sName, "*", sChr)
  sName = Replace(sName, " ", sChr)
  sName = Replace(sName, "{", sChr)
  sName = Replace(sName, "[", sChr)
  sName = Replace(sName, "]", sChr)
  sName = Replace(sName, "}", sChr)
End Sub

Save Selected Messages

This version of the macro saves just the selected messages, not every message in the folder.

Sub SaveSelectedAsDoc()
 
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim Item As Object
Dim dtDate As Date
Dim sName As String

Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection

For Each Item In Selection
    Item.BodyFormat = olFormatRichText
 
'If you want to convert all messages to RTF, uncomment this line.
'Otherwise, the message format is not changed.
   ' Item.Save
 
sName = Item.Subject
ReplaceCharsForFileName sName, "_"
 
dtDate = Item.ReceivedTime
  sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName
         
Item.SaveAs "C:\email\" & sName & ".doc", olDoc 

 
Next Item

Set currentExplorer = Nothing
Set Selection = Nothing
 
End Sub
 
Private Sub ReplaceCharsForFileName(sName As String, sChr As String)
  sName = Replace(sName, "/", sChr)
  sName = Replace(sName, "\", sChr)
  sName = Replace(sName, ":", sChr)
  sName = Replace(sName, "?", sChr)
  sName = Replace(sName, Chr(34), sChr)
  sName = Replace(sName, "<", sChr)
  sName = Replace(sName, ">", sChr)
  sName = Replace(sName, "|", sChr)
  sName = Replace(sName, "&", sChr)
  sName = Replace(sName, "%", sChr)
  sName = Replace(sName, "*", sChr)
  sName = Replace(sName, " ", sChr)
  sName = Replace(sName, "{", sChr)
  sName = Replace(sName, "[", sChr)
  sName = Replace(sName, "]", sChr)
  sName = Replace(sName, "}", sChr)
End Sub

Use an ItemAdd Macro to Save as .Doc

This version of the macro is saves messages as doc files as they are dropped in a folder, either by rules or by dragging the message to the folder. As written, it watches a folder under the Inbox.

Add the ReplaceCharsForFileName sub (from the macro above) at the end of this macro.

Option Explicit
Private objNS As Outlook.NameSpace
Private WithEvents objItems As Outlook.Items

Private Sub Application_Startup()
Dim objFolder As Outlook.folder
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.GetDefaultFolder(olFolderInbox)
Set objItems = objFolder.Folders("Folder01").Items
Set objFolder = Nothing
End Sub

Private Sub objItems_ItemAdd(ByVal aItem As Object)
 
Dim dtDate As Date
Dim sName As String
 
Item.BodyFormat = olFormatRichText
 
'If you want to convert all messages to RTF, uncomment this line.
'Otherwise, the message format is not changed.
   ' Item.Save
 
sName = Item.Subject
ReplaceCharsForFileName sName, "_"
 
 
dtDate = Item.ReceivedTime
  sName = Format(dtDate, "yyyymmdd", vbUseSystemDayOfWeek, _
    vbUseSystem) & Format(dtDate, "hhnnss", _
    vbUseSystemDayOfWeek, vbUseSystem) & "-" & sName
      
Item.SaveAs "C:\email\" & sName & ".doc", olDoc 

End Sub

' put the ReplaceCharsForFileName sub here

Save Messages as *.DOC or *.DOCX File Type was last modified: October 5th, 2020 by Diane Poremsky

Related Posts:

  • Save all incoming messages to the hard drive
  • Save Selected Email Message as .msg File
  • Save email message as text file
  • Save Outlook Email as a PDF

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
32 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Dan (@guest_219173)
February 16, 2022 1:50 am
#219173

Any way to use a Save As Dialog instead, let users choose where to save? Similar to BrowseForFolder but more advanced?

0
0
Reply
James Meadows (@guest_219158)
February 7, 2022 8:48 am
#219158

Diane, It seems that when I really get stumped, and after hours of searching, I eventually find the solution in one your articles. Thank you. What I am trying to do is add the senders name to the outputted file name. It would read Date; Time (if I can figure out how to use colons between the hours and minutes); Subject; From. Is this possible? Also, is it possible to add a bold horizontal line, as in when printing e-mails? Thank you.

0
0
Reply
Brian (@guest_219137)
January 31, 2022 5:36 pm
#219137

Does anyone have an idea why the first set of code would only process 70-72 files before it stops?

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Brian
February 2, 2022 12:46 am
#219143

Any error messages when it stops?

0
0
Reply
Brian (@guest_219146)
Reply to  Diane Poremsky
February 3, 2022 10:39 am
#219146

No error message. It just processes 70 messages and doesn't work. I find 3-4 MS Word docs open on the screen.

0
0
Reply
Aleixa (@guest_217761)
March 13, 2021 9:09 am
#217761

Diane good morning!

I really liked the macros! Especially to save MSG to DOCX.

But with Word 2019 there is a little problem, which I think I solved.
These two lines do not work
'' 'Dim objWord As Word.Application
'' 'Dim objDoc As Word.Document

I moved to:
    Dim objWord As Object
    Dim objDoc As Object
    Set objWord = CreateObject ("Word.Application")
    Set objDoc = objWord.Documents.Add
    objWord.Visible = True

And "FileFormat: = wdFormatXMLDocument" doesn't work either.
I changed it to "FileFormat: = 12" and it worked !!!

I was looking for this macro for some time !! And all the ones I found on the internet didn't work ...

I just want to include the option to choose the directory when saving. But that, I think, is easy.

0
0
Reply
jf83 (@guest_217582)
February 18, 2021 11:55 am
#217582

Hello,

Thanks for the Macros. The save as doc macro works great when I run it but I would like to be able to modify it to be added as a rule. What modifications are needed for that. Thanks

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  jf83
February 18, 2021 2:53 pm
#217584

The itemadd macro would be easiest to change -
Change this
Private Sub objItems_ItemAdd(ByVal aItem As Object)
to
Public Sub SaveFiles(ByVal aItem As Object)

You use any name where I have SaveFiles.

On the others, you change the macro name as above, but also need to remove any lines that set items - like

For Each Item In Selection
For Each Item In mail.Items

as this (ByVal aItem As Object) sets the object passed by the rule.

in those examples, the macros use item as the object name - which is in the macro title: (ByVal aItem As Object) - make sure the object name matches what is in the macro

0
0
Reply
jf83 (@guest_217596)
Reply to  Diane Poremsky
February 19, 2021 10:38 am
#217596

Thanks for the reply. I did not see the ItemAdd Macro before. This will actually work better for me than having a rule! I have tried to set it up but I am getting an error. I copied and pasted the macros along with the Sub from the one above it and changed the name of the folder to the folder I have under my inbox. When I drag an email to the folder I get an error. I have attached a screenshot. Thank you for your help on this.

0
0
Reply
jf83 (@guest_217597)
Reply to  Diane Poremsky
February 19, 2021 11:09 am
#217597

Hello again

I changed (ByVal aItem As Object)  to (ByVal Item As Object) and it is working now. I hope this is the correct way. Thank you again for your help.

0
0
Reply
Esteban Ramos (@guest_212076)
October 12, 2018 10:46 am
#212076

Hello Diane, first of all this is a game changer for me so thank you so much.

Is there a way for the "Save Selected Messages" macro so it saves everything in the email including pictures? (currently pictures inserted do not show up) Does it need to converted to docx instead for it tor work? If so can you tell me what I need to edit?

Thank you so much!!!

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Esteban Ramos
October 13, 2018 10:28 pm
#212081

Do you want to save the embedded pictures as individual images or embedded in the file?

0
0
Reply
Craig (@guest_211396)
June 26, 2018 4:33 pm
#211396

Hello Diane,

I'm using the 'Save Selected Messages' version of your script and it worked great for me, but for one item. The message in Outlook 2016 gets converted to RTF for the save and stays that way in Outlook, but I never uncommented the "save" line:

'If you want to convert all messages to RTF, uncomment this line.
'Otherwise, the message format is not changed.
' Item.Save

Any suggestions as to why it is changing the email to RTF and not reverting it back to HTML? I have tried restarting Outlook to see if it was just temporary, but the message that I saved to file is still in RTF om Outlook.

0
0
Reply
Dave (@guest_211044)
May 11, 2018 9:14 pm
#211044

Hi Diane, can this macro be altered to save messages as .docx?
I'm using the macro, which is great, but I'm finding I continually need to convert docs to docx, any suggestions?

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Dave
May 11, 2018 9:58 pm
#211045

Yes, it can save as docx - you need to use the pdf macro and change the file type - https://www.slipstick.com/developer/code-samples/save-outlook-email-pdf/

wrdApp.ActiveDocument.SaveAs2 FileName:= _
strToSaveAs, FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False, CompatibilityMode:=15

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 19

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment