• Outlook User
  • Exchange Admin
  • Office 365
  • Outlook Developer
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
    • Common Problems
    • Outlook BCM
    • Utilities & Addins

How to backup and save your Outlook VBA macros

Slipstick Systems

› Developer › How to backup and save your Outlook VBA macros

Last reviewed on October 25, 2015     28 Comments

Applies to: Outlook 2013, Outlook 2010, Outlook 2007

After you create a VBA macro in Outlook, how do you back it up, save a copy, or copy it to a new computer?

There are three ways to make a copy of your macros:

Method 1

Copy the contents of ThisOutlookSession (and any modules) and paste into notepad, saving the macro(s) as a text file.

Export VBAPorject or modules to back them up

Method 2

Right click on ThisOutlookSession and choose Export File. You'll need to do for each module (if any) in your Project.

Method 3

Close Outlook and locate the VBAProject file. Copy it to make a backup.

In Windows 7, 8, or Vista, paste %appdata%\microsoft\outlook in the address bar of Windows Explorer and press Enter to jump to the C:\Users\username\AppData\Roaming\Microsoft\Outlook folder where VBAProject.OTM is. Copy it to make a backup.

In Windows XP, paste %USERPROFILE%\Application Data\Microsoft\Outlook in the address bar of Windows Explorer and press Enter. This will open Windows Explorer to C:\Documents and Settings\username\Application Data\Microsoft\Outlook. Copy the VBAProject.OTM file.

Which method is better? It really depends on your needs. Copying the VBAProject.OTM file insures you have everything in the project and can drop it in the Outlook folder to restore the macros. Copying the code to a text file may be easier to share with others or to copy some macros to another computer that has Outlook macros already in use.

How to backup and save your Outlook VBA macros was last modified: October 25th, 2015 by Diane Poremsky
  • Twitter
  • Facebook
  • LinkedIn
  • Reddit
  • Print

Related Posts:

  • Outlook Backup and Dual-Boot File Locations
  • How to use a batch file to backup Microsoft Outlook personal files (*.
    Backup Outlook Data Files using a Batch (.bat)
  • What to backup in Outlook 2013 and newer
  • Outlook Crashes During Send & Receive

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
28 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Ragnar Moller (@guest_220032)
January 30, 2023 9:12 am
#220032

Hi,

Outlook crashes on me when I do Developer / Visual Basic, so none of the methods are useable. I suppose the VbaProjet.OTM is the source of the crash.

How can I avoid this and save my code base ?

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Ragnar Moller
January 30, 2023 11:19 am
#220033

The OLM is corrupt and unfortunately there is no method to repair it. Close Outlook and rename the OLM file at
C:\Users\%username%\AppData\Roaming\Microsoft\Outlook to create a new one or, restore a backup if you have one.

How extensive are the macros? You won't be able to get more than the module names and little bits of code from the olm file (opened in notepad). When mine was corrupted, it had a bunch of php scripts added to it for some reason. (They were scripts I wrote for another application.)

I now try to remember to drag modules to a folder on my hard drive after editing - I sometimes forget but at least I will have something to work with if it gets corrupted again.

0
0
Reply
Ragnar Moller (@guest_220034)
Reply to  Diane Poremsky
January 30, 2023 11:28 am
#220034

Hi Diane,

For me the file is not yet corrupt since Outlook reads it and partly executes the macro's
am I wrong ?

Maybe I just don't want to accept reality ...

All of my code is VBA basically, no PHP scripts

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Ragnar Moller
January 30, 2023 12:30 pm
#220035

I think it is still corrupt. If you cant open the editor, there is no way to make a copy of the macros or edit it and there is no way to repair it.

Is the size of the OLM file on your hard drive about what you'd expect for the number of macros? Obviously hard to know for sure - but mine was around 3MB when it went bad. I had problems with it before and it seemed to happen when the file approached 3MB.

My current olm files is around 600 KB - 26 modules - some have macro just a few lines, other have 2 or 3 macros with 20 or 30 lines.

Close Outlook, make a copy of the olm and open it in notepad. Eyeball it and see if there appears to be any code in it that doesn't belong.

0
0
Reply
BobH (@guest_219734)
September 23, 2022 11:55 am
#219734

Please disregard/delete last post - after explicitly saving the vbaproject.otm project on the source, the copy worked.

1
0
Reply
BobH (@guest_219733)
September 23, 2022 11:46 am
#219733

I copied the vbaproject.otm file from one computer to another using the path you described. (for both source and destination). Windows File Explorer confirmed that it replaced what was there, but when I opened Outlook, none of the code changes in the source vbaproject.otm appeared. I know there are known problems with vbaproject.otm (such as time/date stamp never updating), but I have no clue on this one - will be forced to use module export/import.

0
0
Reply
Marek (@guest_219223)
April 21, 2022 1:44 pm
#219223

Hi, I hope it is possible to write a macro that will go through all modules of the project and save each of them in *.bas format in a selected folder. I do not seem I can get such a simple logic in VBA. Could you help?

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Marek
April 21, 2022 9:38 pm
#219225

Outlook's VB object model doesn't support exporting the modules using code. You can drag them to File Explorer (its faster than using File > Save) - but need to do it one at a time.

0
0
Reply
Michael Houle (@guest_217563)
February 12, 2021 12:42 pm
#217563

Based on this write up. We can transport the macro to another outlook instance. But the macro I wrote ends up with a button on the ribbon. Would that still need to be done manually?
I'm looking to push this out to all of our computers. We already know we can do an export/import. We are trying to push this out silently with little to no user involvement.

0
0
Reply
TheDavidSlight (@guest_215384)
June 9, 2020 7:25 pm
#215384

Looks like the copy OTM method finally dies - getting this new pop-up for the first time ever after all these years:
Office has identified a potential security concern Warning the digital signature has been tampered with.

Annotation 2020-06-09 162604.jpg
0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  TheDavidSlight
June 9, 2020 10:28 pm
#215388

Are you using signed macros? Was the otm you copied signed with the same digital signature as the one it replaced?

0
0
Reply
TheDavidSlight (@guest_215391)
Reply to  Diane Poremsky
June 10, 2020 1:09 am
#215391

Yes to signed (with SelfCert). But the not the same cert as the destination was / is a new insider build. But this approach has always worked in the past -- I keep a copy of the OTM and move it into the folder on the new build and off we go.

0
0
Reply
Heather (@guest_192346)
August 6, 2015 3:12 am
#192346

Thank you Diane.

What is the name of the xml file and where will I find it?

Heather

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Heather
August 6, 2015 8:13 pm
#192372

it's "Outlook Customizations (olkexplorer).exportedUI" - you can save it anywhere for easy access, default location should be in documents.

0
0
Reply
Heather (@guest_192309)
August 5, 2015 8:20 am
#192309

I am having a similar problem in Outlook 2010, but in addition to the code I need to back up the icon assigned to the macro on my QAT. Anyone got ideas?

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Heather
August 5, 2015 11:06 am
#192310

if you export the customizations, the icon you assigned to the button is included in the xml file that holds the customizations.

0
0
Reply

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

Latest EMO: Vol. 28 Issue 11

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?

Subscribe to Exchange Messaging Outlook






Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • WeekMonthAll
  • Adjusting Outlook's Zoom Setting in Email
  • How to Remove the Primary Account from Outlook
  • Cannot add Recipients in To, CC, BCC fields on MacOS
  • Move an Outlook Personal Folders .pst File
  • Save Sent Items in Shared Mailbox Sent Items folder
  • Create rules that apply to an entire domain
  • Outlook's Left Navigation Bar
  • Remove a password from an Outlook *.pst File
  • Use PowerShell to get a list of Distribution Group members
  • View Shared Calendar Category Colors
  • Cannot add Recipients in To, CC, BCC fields on MacOS
  • Change Appointment Reminder Sounds
  • Messages appear duplicated in message list
  • Reset the New Outlook Profile
  • Delete Old Calendar Events using VBA
  • Use PowerShell or VBA to get Outlook folder creation date
  • Outlook's Left Navigation Bar
  • Contact's Display Bug
  • Use PowerShell to get a list of Distribution Group members
  • Edit Outlook’s Attach File list
Ajax spinner

Newest Code Samples

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

Format Images in Outlook Email

Set Outlook Online or Offline using VBScript or PowerShell

List snoozed reminders and snooze-times

Search your Contacts using PowerShell

Filter mail when you are not the only recipient

Add Contact Information to a Task

Process Mail that was Auto Forwarded by a Rule

Recent Bugs List

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

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

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.

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

Other Microsoft 365 applications and services




Windows 10 Issues

  • iCloud, Outlook 2016, and Windows 10
  • Outlook Links Won’t Open In Windows 10
  • Outlook can’t send mail in Windows 10: error Ox800CCC13
  • Missing Outlook data files after upgrading Windows?

Outlook Top Issues

  • The Windows Store Outlook App
  • The Signature or Stationery and Fonts button doesn’t work
  • Outlook’s New Account Setup Wizard
  • Outlook 2016: No BCM
  • Exchange Account Set-up Missing in Outlook 2016

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

Outlook-tips.net Samples

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

MSDN Outlook Dev Forum

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

Contact Tools

Data Entry and Updating

Duplicate Checkers

Phone Number Updates

Contact Management Tools

Diane Poremsky [Outlook MVP]

Make a donation

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

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

Outlook Suggestion Box (UserVoice)

Slipstick Support Services

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 | Advertise | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2023 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