运行时错误424 - Outlook VBA中的对象所需错误

时间:2015-05-07 15:04:05

标签: excel-vba vba excel

我在Outlook VBA中运行此代码。它昨天工作正常,但它今天给出了这个错误。当我今天上任时,我发现我的电脑重新启动是因为一些夜间更新。这与此有关吗?

Sub test()
    Dim mtd As String

    mydate = Format(Date - 1, "yyyyMMdd")

    Dim xlApp As Object
    Dim sourceWB

    Set xlApp = CreateObject("Excel.Application") 'error occurs on this line

    With xlApp
        .Visible = True
        .EnableEvents = False
    End With

    strFile = "\\disk24\ontime-shared\OTP\Reports\Daily_OTP\" & "Operational_Recap_" & mydate & ".xls"

    Set sourceWB = xlApp.Workbooks.Open(strFile, , False, , , , , , , True)
    sourceWB.Worksheets("Summary").Select
    sourceWB.Activate
End Sub

0 个答案:

没有答案