2016-04-25 1608 views
1

我有一个Outlook项目,将所有附件从选定电子邮件保存到特定位置。 然后我有Excel工作簿,它包含宏,它检查存储的文件并做一些事情。 我想调用Excel从Outlook项目宏,但我发现了错误:通过Outlook运行Excel宏:运行时错误“-2147417851(80010105)'

运行时错误 '-2147417851(80010105)' Method对象的 '运行' '_Application' 失败

代码,在那里我得到的错误是:

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冻结,我必须关闭它使用任务管理器。

回答

0

尝试,而不是你示数就行了这一点:

check_RDS.Run "'gatekeeper.xlsm'!test", readROW, strFolderPath

+0

运行时错误“438”:对象不支持此属性或方法 –