简体   繁体   中英

Excel Error Handling not Stopping Sheet Select Pop-Up

I've created a function which checks if a sheet exists in an external workbook. Code as follows (I've checked this and this works perfectly with other sheets, commenting out the If statement that references this stops the error):

Function ExtSheetExists(formString) As Boolean
    Dim val As Variant
    On Error Resume Next
    val = ExecuteExcel4Macro(formString)
    ExtSheetExists = (val <> Error(2023))
    On Error GoTo 0
End Function

Note: FormString is passed as "'" & wkBookRef1 & firstShtName & "'!" & "R6C12" "'" & wkBookRef1 & firstShtName & "'!" & "R6C12" where wkBookRef1 is just the path to the spreadsheet and firstShtName is the spreadsheet name that is being looked up.

However later when I go to update the same spreadsheet using the UpdateLink method it pops up the Select Sheet dialogue box and thus stops the run of the macro. Does anyone have an inkling as to what is going on here?

The select sheet box is as follows:

选择工作表弹出框

It's a bug. Effectively the formstring is run and the message box is suppressed. However it seems that it remains as a latent process in the other spreadsheet. So when it is updated it shows the suppressed message box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM