从Outlook 16调用Excelmacros

我遇到一些令人头痛的问题,请致电我的personal.xlsm中包含的Excelmacros,请帮助我。

我正在运行Outlook 2016.尝试在打开Outlook时从personal.xlsm调用macros。 关键问题(我认为基于其他解决scheme)是正确的Excel数据对象库不包括在内,但我已经包括似乎是相关的(没有成功)。

包括

该程序只是运行而不调用macros – 我已经放在Excelmacros的开始MsgBox提示检查是否开始运行&每次失败。

从下面的代码中提取; 我已经删除了与这个问题无关的代码。

在outlook:ThisSession

Private Sub Application_Startup() Dim macroFile As String, networkFilePath As String, sourceFile as String Dim DestFile As String: DestFile = "FolderTree.csv" Dim SourceFolder As String: SourceFolder = "[NetworkLocation]" Dim foldersRequired As String Dim objShell As Object Dim objFile As Object Dim fso As FileSystemObject: Set fso = CreateObject("Scripting.FileSystemObject") Dim xlApp As Object: Set xlApp = CreateObject("Excel.Application") 'open the excel csv source file Dim xlWkb As Object, xlSht As Object On Error Resume Next ''get the core xlsb macros file - saves updating the individual user outlook macroFile = userProfilePath & "\Personal.xlsb" 'This works fine & opens the file with no issues. Set xlWkb = xlApp.Workbooks.Open(macroFile) Set xlSht = xlWkb.Worksheets(1) xlApp.Application.Visible = True '' extract the users profile path Set objShell = CreateObject("WScript.Shell") userProfilePath = objShell.ExpandEnvironmentStrings("%UserProfile%") & "[DataFolder]" sourceFile = userProfilePath & "\" & DestFile xlApp.Workbooks("Personal.xlsb").Activate xlApp.Workbooks.Open FileName:=(sourceFile) '' This opens fine If Not xlxApp Is Nothing Then '' None of the below work xlWkb.Application.Run "Module1.Clean_CSV(sourceFile, userProfilePath)" '' This doesn't work xlWkb.Application.Run "Personal.xlsb!Module1.Clean_CSV(sourceFile, userProfilePath)" '' This doesn't work xlWkb.Application.Run "Personal.xlsb!Clean_CSV(sourceFile, userProfilePath)" '' This doesn't work End If xlApp.Close xlApp.Quit '' I set all Variables & Objects to Nothing & then End Sub 

Exceltestingmacros的屏幕截图