Vba 通过Outlook运行Excel宏:运行时错误'-2147417851(80010105)和#x27;
我有一个Outlook项目,可以将选定电子邮件中的所有附件保存到特定位置。 然后我有Excel工作簿,它包含宏,检查存储的文件并做一些事情。 我想从Outlook项目调用Excel宏,但出现错误: 运行时错误“-2147417851(80010105)”对象“\u应用程序”的方法“运行”失败 代码,我得到的错误是:Vba 通过Outlook运行Excel宏:运行时错误'-2147417851(80010105)和#x27;,vba,excel,outlook,Vba,Excel,Outlook,我有一个Outlook项目,可以将选定电子邮件中的所有附件保存到特定位置。 然后我有Excel工作簿,它包含宏,检查存储的文件并做一些事情。 我想从Outlook项目调用Excel宏,但出现错误: 运行时错误“-2147417851(80010105)”对象“\u应用程序”的方法“运行”失败 代码,我得到的错误是: Sub CheckRDSFiles() Dim fso As New FileSystemObject Dim files As TextStream
Sub CheckRDSFiles()
Dim fso As New FileSystemObject
Dim files As TextStream
Dim strFolderPath As String
Dim exApp As Excel.Application
Dim check_RDS As Workbook
Dim readROW As String
'Create complete folder to save files
strFolderPath = SAVE_TO_FOLDER & Format(Now, "MMMM") & "\" & Format(Date, "yyyy-MM-DD") & "\"
'File that stores files to be processed
Set files = fso.OpenTextFile(strFolderPath & "files.txt", ForReading, True, TristateUseDefault)
'Create excel application and open excel workbook with macro
Set exApp = New Excel.Application
Set check_RDS = exApp.Workbooks.Open(CHECK_RDS_PATH)
exApp.Visible = True
'Reading file
Do Until files.AtEndOfStream
'each line represent path to one file
readROW = files.ReadLine
Debug.Print readROW
'call macro from workbook "gatekeeper.xlsm" in module "Test" with name "test" and with parametres
check_RDS.Application.Run "gatekeeper.xlsm!Test.test", readROW, strFolderPath
Loop
End Sub
错误在线:
check_RDS.Application.Run "gatekeeper.xlsm!Test.test", readROW, strFolderPath
有趣的是,我可以偶尔毫无问题地运行它,但每次都需要毫无问题地运行它
此外,当我出现此错误时,我的Excel会冻结,我必须使用任务管理器将其关闭。请尝试此操作,而不是您正在出错的行:
检查RDS.Run“'gatekeeper.xlsm'!test”,readROW,strFolderPath
尝试以下操作,而不是在您出错的行上:
检查RDS.Run“'gatekeeper.xlsm'!test”、readROW、strFolderPath
运行时错误“438”:对象不支持此属性或方法运行时错误“438”:对象不支持此属性或方法