We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Remotely remove code from "ThisOutlookSession" (VbaProject.otm)

parinpatel asked
Medium Priority
Last Modified: 2012-05-06
We have some custom code added to "ThisOutlookSession" for all computers.  The vba project is also signed with a digital certificate created with selfcert.exe.  We no longer need the functionality that the code was providing and need to remove the code from all computers.  What is the best / cleanest way to do this remotely?  From my understanding the VbaProject.otm is the file getting saved when the code was added to "ThisOutlookSession".  In testing this, simply deleting, renaming or moving the VbaProject.otm from %userprofile%\application data\microsoft\outlook does the trick.  The file cannot be deleted, renamed or removed while Outlook is running.  Or, manually removing the actual code from the vba project and saving the blank file also works.  There are multiple profiles on many of the computers and we need to removed the code / file from All profiles.

1.  Is this a safe way to go about getting rid of this code?
2.  Do we have to do anything with the digital certificate created with selfcert.exe that was being used to sign the vba project or can it just hang around?
3.  Is there a way to remotely remove the file and / or code via Group Policy (start up scripts, etc.)?
Watch Question

Top Expert 2010
Hi, parinpatel.

There is no good way to do this.  Microsoft apparently never envisioned sharing Outlook macro code and thus provided no means for managing it.  Outlook stores ALL its code in the file VbaProject.OTM, not just code in ThisOutlookSession.  

1.  That depends on what you mean by safe.  There is NO means of removing the code.  You cannot manipulate code in Outlook from code (i.e. there's no means of scripting the addition, change, or removal of code that's in Outlook).

2.  The cert will be fine, but you're almost certainly going to be forced to sign the code again.

3.  The only automated means of removing the code is to replace the .OTM file.  You can do that from a login scipt by simply overwriting the file with a replacement file.  Keep in mind though that if any of your staff have any other code in Outlook, then overwriting the file is going to erase it.  

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Thanks much BlueDevilFan.
Top Expert 2010

You're welcome.  Glad I could help.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.