• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1749
  • Last Modified:

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

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.)?
  • 2
1 Solution
David LeeCommented:
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.  
parinpatelAuthor Commented:
Thanks much BlueDevilFan.
David LeeCommented:
You're welcome.  Glad I could help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now