Call outlook VBA from Excel

后端 未结 2 1087
挽巷
挽巷 2020-12-06 15:32

I have a function in the outlook VBA that I want to call when a certain excel workbook is closed. Is there a way to do this with the BeforeClose event of excel? I know how t

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 15:41

    MS Office applications can interact with each other by this method (this is based on Office 2007, but others will be similar):

    Add a reference to the app into Excel

    In Excel VBA, from the Tools\References menu select Microsoft Outlook 12.0 Object Library

    In your BeforeClose Event include

    Dim olApp As Outlook.Application
    Set olApp = New Outlook.Application
    

    You can now access Outlook through the olApp object. I don't know much about the Outlook object model, so others may be able help more from here on...

提交回复
热议问题