Application_Startup() not firing

前端 未结 4 445
梦谈多话
梦谈多话 2021-01-16 03:03

I\'ve code in the \"ThisOutlookSession\" module.

Application_ItemSend works, events are triggered when sending mail.

Application_Startup runs when I initiate

相关标签:
4条回答
  • 2021-01-16 03:17

    I tested your code and I’ve ran into the same problem. I have solved this problem by restarting my PC and adding the Public Sub Application_Quit() method.

    0 讨论(0)
  • 2021-01-16 03:23

    Had a similar problem. Application_Startup didn't trigger on restarting Outlook and hence my changes in the function didn't load. The reason Application_Startup didn't trigger was because I had another program holding a reference open to Outlook

    0 讨论(0)
  • 2021-01-16 03:28

    There seems to be a flag in outlook which checks for VBA code. If it can't find any it sets the registry value (HKEY_CURRENT_USER\Software\Microsoft\Office\XX.0\Outlook\LoadMacroProviderOnBoot) to 0 every time it closes. It doesn't seem to be setup so that it detects when code is added by copying the OTM file. I have discovered 2 scenarios (there may be more) which cause the flag to be set causing outlook to change the registry value to 1 on close.

    1. If any macro is run
    2. The visual basic editor is opened.

    The issue arose in my situation when I try to roll out the VBA code to a new PC with no existing VBA code.

    I use a batch script to roll out my VBA code to other machines and to fix it I simply added a REG ADD command to the bat file after the code is copied to the machine which sets the key to 1.

    REG ADD HKCU\Software\Microsoft\Office\XX.0\Outlook /v LoadMacroProviderOnBoot /t REG_DWORD /d 1 /f

    You need to change “XX.0” to the version of office you are dealing with. Check the registry to find out.

    This seems to force Outlook to check for VBA code when it starts.

    (Thanks to Sergik718 on Microsoft TechNet forums for pointing out that changing this registry entry helps.)

    0 讨论(0)
  • 2021-01-16 03:30

    Was experiencing same problem with Application_Startup() procedure not firing after a system reload and restore of my VBAProject. Checked macro settings, digitally signed the project - no luck. Received no button to Enable VBA during startup, like in Office 2010. VBA would function, but required me to manually fire the Application_Startup() procedure.

    Tried creating a new, temporary "Private Application_Startup()" procedure, but no joy.

    I deleted "Public" statement that preceded the Application_Startup() declaration. Saved, closed VBA and Outlook. Re-opened and suddenly it started working. Have restored the "Public", saved, re-opened, and it now seems to work properly. No explanation.

    0 讨论(0)
提交回复
热议问题