Outlook存储VBA代码文件在哪里?

时间:2022-06-19 00:02:50

I had a VBA project in outlook with a few email macros - but after a PC crash they are all gone and all I see is a fresh 'Project1' when I hit Alt+F11

我在Outlook中有一个带有几个电子邮件宏的VBA项目 - 但是在PC崩溃后它们都消失了,当我点击Alt + F11时,我看到的只是一个新的'Project1'

I'm not a VBA programmer, but had a collection of handy macros for email sorting etc. I would not like to have to code them again. Anyone know where the code files should be on the filesystem so that I might rescue the code?

我不是VBA程序员,但有一组方便的宏用于电子邮件排序等。我不想再次编写代码。任何人都知道代码文件应该在文件系统上的哪个位置,以便我可以挽救代码?

4 个解决方案

#1


22  

This page has some really good insight on where Outlook keeps all its stuff. It suggests the following:

这个页面对Outlook保留所有内容的地方有一些非常好的见解。它建议如下:

All Outlook macros are stored in a single file named VbaProject.otm in the user's %appdata%\Microsoft\Outlook folder, which will be a hidden folder on most systems.

所有Outlook宏都存储在用户的%appdata%\ Microsoft \ Outlook文件夹中名为VbaProject.otm的单个文件中,该文件夹将是大多数系统上的隐藏文件夹。

Now, the problem is that if you do not see them now, then you probably won't be able to restore them from that location: there is probably either an "empty" project there or no project at all, but if that folder is being backed up, you might be able to restore it.

现在,问题是,如果你现在没有看到它们,那么你可能无法从那个位置恢复它们:可能有一个“空”项目或根本没有项目,但如果该文件夹是备份后,您可以恢复它。

Moving forward, you might consider exporting your macros periodically in case this happens again, either through the VBA IDE (right-click and select Export File...) or using one of the tools mentioned in the linked article (like the Office Profile Wizard).

接下来,您可以考虑定期导出宏,以防再次发生这种情况,通过VBA IDE(右键单击并选择导出文件...)或使用链接文章中提到的工具之一(如Office配置文件向导) )。

#2


3  

Ok. things to try to fix this...

好。试图解决这个问题的事情......

I assume after the problem occured you tried logging back into the same windows user account, and the same Outlook profile.

我假设在发生问题之后您尝试重新登录到相同的Windows用户帐户和相同的Outlook配置文件。

  1. Create a new windows login to the machine in question.
  2. 创建一个新的Windows登录到相关的机器。

  3. Login to this account and open Outlook, this will create a new outlook profile. make note of the profile name (to find this: Control Panel > Mail applet > Show Profiles...)
  4. 登录此帐户并打开Outlook,这将创建一个新的Outlook配置文件。记下配置文件名称(查找此信息:控制面板>邮件小程序>显示配置文件...)

  5. Now Exit Outlook, and make sure it is not running (check for outlook.exe in task manager).
  6. 现在退出Outlook,并确保它没有运行(检查任务管理器中的outlook.exe)。

  7. Open Windows Explorer.
  8. 打开Windows资源管理器

  9. Copy (don't cut) the existing VbaProject.OTM file. (if it has any other name than that, first rename it to VbaProject.OTM, then copy).
  10. 复制(不剪切)现有的VbaProject.OTM文件。 (如果它有任何其他名称,首先将其重命名为VbaProject.OTM,然后复制)。

  11. Navigate to C:\Documents and Settings\USERNAME\Application Data\Microsoft\Outlook (or use the environment variable notation %appdata%\Microsoft\Outlook for vista/win7)
  12. 导航到C:\ Documents and Settings \ USERNAME \ Application Data \ Microsoft \ Outlook(或使用环境变量表示法%appdata%\ Microsoft \ Outlook for vista / win7)

  13. Rename the existing VbaProject.OTM to VbaProject.OTM.OLD
  14. 将现有的VbaProject.OTM重命名为VbaProject.OTM.OLD

  15. Paste the VbaProject.OTM from step 5 into this folder.
  16. 将步骤5中的VbaProject.OTM粘贴到此文件夹中。

  17. Reopen Outlook and test (i.e. Alt + F11).
  18. 重新打开Outlook并测试(即Alt + F11)。

  19. Good luck with recovery.
  20. 康复好运。

If this doesn't work do you remember adding self signing certificate at all? If so have you got a copy of the cert? you can try reinstalling it into the certificate manager (certmgr.msc) copy/install it to the Certficiates - Current User\Personal\Certificates hive.

如果这不起作用,您还记得添加自签名证书吗?如果是这样,你有一份证书副本?您可以尝试将其重新安装到证书管理器(certmgr.msc)中,将其复制/安装到Certficiates - 当前用户\个人\证书配置单元。

I just found this note from Sue Mosher (outlook VBA guru): "AFAIK, once an .otm file is corrupted, it can't be recovered. That's why I recommend that people who rely on VBA code export their modules or backup the entire file. "

我刚刚从Sue Mosher(Outlook VBA大师)发现了这个说明:“AFAIK,一旦.otm文件损坏,就无法恢复。这就是为什么我建议那些依赖VBA代码的人导出他们的模块或备份整个档案。“

#3


2  

All macros are embedded into an OTM file, under the following location:

所有宏都嵌入到OTM文件中,位于以下位置:

C:\Users\(***Your User Name***)\AppData\Roaming\Microsoft\Outlook\VbaProject.OTM

To restore, replace this file with the older one, it should work

要恢复,请将此文件替换为旧文件,它应该可以正常工作

#4


-1  

Ran into this same problem. None of the "answers" helped me, so I did my own digging. I found the .OTM file that both @Anonymous Type and @Dave DuPlantis had mentioned. But it isn't corrupted, not even sure how one could determine that your file was corrupted from your very vague question... Either way, here is my solution.

陷入同样的​​问题。没有一个“答案”帮助了我,所以我自己进行了挖掘。我找到了@Anonymous Type和@Dave DuPlantis提到的.OTM文件。但它没有被破坏,甚至不确定如何确定你的文件已经从你非常模糊的问题中被破坏了...无论哪种方式,这是我的解决方案。

Check your Ribbon. Is the Developer tab there? If not, then enabling it should solve your problem. Simple. Not sure why or how it spontaneously disappeared though, thats a whole new puzzle...

检查功能区。是开发人员选项卡吗?如果没有,那么启用它应该可以解决您的问题。简单。不知道为什么或如何自发消失,这是一个全新的难题......

#1


22  

This page has some really good insight on where Outlook keeps all its stuff. It suggests the following:

这个页面对Outlook保留所有内容的地方有一些非常好的见解。它建议如下:

All Outlook macros are stored in a single file named VbaProject.otm in the user's %appdata%\Microsoft\Outlook folder, which will be a hidden folder on most systems.

所有Outlook宏都存储在用户的%appdata%\ Microsoft \ Outlook文件夹中名为VbaProject.otm的单个文件中,该文件夹将是大多数系统上的隐藏文件夹。

Now, the problem is that if you do not see them now, then you probably won't be able to restore them from that location: there is probably either an "empty" project there or no project at all, but if that folder is being backed up, you might be able to restore it.

现在,问题是,如果你现在没有看到它们,那么你可能无法从那个位置恢复它们:可能有一个“空”项目或根本没有项目,但如果该文件夹是备份后,您可以恢复它。

Moving forward, you might consider exporting your macros periodically in case this happens again, either through the VBA IDE (right-click and select Export File...) or using one of the tools mentioned in the linked article (like the Office Profile Wizard).

接下来,您可以考虑定期导出宏,以防再次发生这种情况,通过VBA IDE(右键单击并选择导出文件...)或使用链接文章中提到的工具之一(如Office配置文件向导) )。

#2


3  

Ok. things to try to fix this...

好。试图解决这个问题的事情......

I assume after the problem occured you tried logging back into the same windows user account, and the same Outlook profile.

我假设在发生问题之后您尝试重新登录到相同的Windows用户帐户和相同的Outlook配置文件。

  1. Create a new windows login to the machine in question.
  2. 创建一个新的Windows登录到相关的机器。

  3. Login to this account and open Outlook, this will create a new outlook profile. make note of the profile name (to find this: Control Panel > Mail applet > Show Profiles...)
  4. 登录此帐户并打开Outlook,这将创建一个新的Outlook配置文件。记下配置文件名称(查找此信息:控制面板>邮件小程序>显示配置文件...)

  5. Now Exit Outlook, and make sure it is not running (check for outlook.exe in task manager).
  6. 现在退出Outlook,并确保它没有运行(检查任务管理器中的outlook.exe)。

  7. Open Windows Explorer.
  8. 打开Windows资源管理器

  9. Copy (don't cut) the existing VbaProject.OTM file. (if it has any other name than that, first rename it to VbaProject.OTM, then copy).
  10. 复制(不剪切)现有的VbaProject.OTM文件。 (如果它有任何其他名称,首先将其重命名为VbaProject.OTM,然后复制)。

  11. Navigate to C:\Documents and Settings\USERNAME\Application Data\Microsoft\Outlook (or use the environment variable notation %appdata%\Microsoft\Outlook for vista/win7)
  12. 导航到C:\ Documents and Settings \ USERNAME \ Application Data \ Microsoft \ Outlook(或使用环境变量表示法%appdata%\ Microsoft \ Outlook for vista / win7)

  13. Rename the existing VbaProject.OTM to VbaProject.OTM.OLD
  14. 将现有的VbaProject.OTM重命名为VbaProject.OTM.OLD

  15. Paste the VbaProject.OTM from step 5 into this folder.
  16. 将步骤5中的VbaProject.OTM粘贴到此文件夹中。

  17. Reopen Outlook and test (i.e. Alt + F11).
  18. 重新打开Outlook并测试(即Alt + F11)。

  19. Good luck with recovery.
  20. 康复好运。

If this doesn't work do you remember adding self signing certificate at all? If so have you got a copy of the cert? you can try reinstalling it into the certificate manager (certmgr.msc) copy/install it to the Certficiates - Current User\Personal\Certificates hive.

如果这不起作用,您还记得添加自签名证书吗?如果是这样,你有一份证书副本?您可以尝试将其重新安装到证书管理器(certmgr.msc)中,将其复制/安装到Certficiates - 当前用户\个人\证书配置单元。

I just found this note from Sue Mosher (outlook VBA guru): "AFAIK, once an .otm file is corrupted, it can't be recovered. That's why I recommend that people who rely on VBA code export their modules or backup the entire file. "

我刚刚从Sue Mosher(Outlook VBA大师)发现了这个说明:“AFAIK,一旦.otm文件损坏,就无法恢复。这就是为什么我建议那些依赖VBA代码的人导出他们的模块或备份整个档案。“

#3


2  

All macros are embedded into an OTM file, under the following location:

所有宏都嵌入到OTM文件中,位于以下位置:

C:\Users\(***Your User Name***)\AppData\Roaming\Microsoft\Outlook\VbaProject.OTM

To restore, replace this file with the older one, it should work

要恢复,请将此文件替换为旧文件,它应该可以正常工作

#4


-1  

Ran into this same problem. None of the "answers" helped me, so I did my own digging. I found the .OTM file that both @Anonymous Type and @Dave DuPlantis had mentioned. But it isn't corrupted, not even sure how one could determine that your file was corrupted from your very vague question... Either way, here is my solution.

陷入同样的​​问题。没有一个“答案”帮助了我,所以我自己进行了挖掘。我找到了@Anonymous Type和@Dave DuPlantis提到的.OTM文件。但它没有被破坏,甚至不确定如何确定你的文件已经从你非常模糊的问题中被破坏了...无论哪种方式,这是我的解决方案。

Check your Ribbon. Is the Developer tab there? If not, then enabling it should solve your problem. Simple. Not sure why or how it spontaneously disappeared though, thats a whole new puzzle...

检查功能区。是开发人员选项卡吗?如果没有,那么启用它应该可以解决您的问题。简单。不知道为什么或如何自发消失,这是一个全新的难题......