CreateObject randomly throws “A system shutdown has already been scheduled” error

后端 未结 1 2031
星月不相逢
星月不相逢 2021-01-02 09:01

I googled and SO\'d, and nothing.

My job revolves around making my co-workers lives easier.

Currently, they are using very clunky spreadsheets designed 10+ y

相关标签:
1条回答
  • 2021-01-02 09:34

    With errors this seemingly-unrelated and intermittent, I usually opt for either a bit of delay, catching the error and retrying or both.

    Try the following (retry without a delay):

    Function gogogo(sessKey)
    On Error GoTo ErrHandler
        reportId = Sheet2.Range("A" & (Sheet2.Range("B1").Value + 1)).Value
        Set objIE = CreateObject("InternetExplorer.Application")
        URL = "http://localinternetdomainhere/OnlineTools/" & reportId & "/access/" & sessKey
        With objIE
            .Visible = True
            .navigate URL
        End With
        ThisWorkbook.Saved = True
        ThisWorkbook.Close False
        Exit Function
    
    ErrHandler:
    
        If Err.Number = &H800704A6 Then 'Put a breakpoint here to make sure this is the ACTUAL VBA error number and not the ActiveX one. You might need to check against the Err.LastDllError property
            Resume
        End If
        Err.Raise Err.Number, Err.Source, Err.Description,err.HelpFile, err.HelpContext 'Reraise the error otherwise
    
    End Function
    
    0 讨论(0)
提交回复
热议问题