简体   繁体   English

Excel错误处理未停止工作表选择弹出窗口

[英]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): 代码如下(我已经检查了这一点,并且可以与其他工作表完美配合,注释掉引用了此内容的If语句可以停止错误):

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" 注意: FormString传递为"'" & 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. "'" & wkBookRef1 & firstShtName & "'!" & "R6C12" ,其中wkBookRef1只是电子表格的路径,而firstShtName是要查找的电子表格名称。

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. 但是,稍后当我使用UpdateLink方法更新同一电子表格时,它将弹出“选择工作表”对话框,从而停止运行宏。 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. 有效地运行formstring并取消显示消息框。 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. 因此,更新后会显示禁止显示的消息框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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