I am executing the Excel 'Debug -> Compile VBAProject' from a VBA project like below,
Public Function CheckForCompilerErrors()
On Error GoTo compileerr
ExcelObject.ActiveWorkbook.VBProject.VBE.CommandBars.findcontrol(ID:=578).Execute
Exit Function
compilerErr:
MsgBox "Compilation failed. Give Debug->Compile VBAProject and fix the compilation errors."
End Function
Here after running the .Execute
, Excel VBA is throwing the error "Compiler Error: User-defined type not defined.".
But actually I want to suppress this Excel VBA error. That's the reason why I added error handler. But in the above case, it is not going to error handler.
Maybe what I am suspecting is, since the .Execute
got successfully called (which invokes Debug->Compile VBAProject) whether there is any error or not, it returns success and not going to error handler.
Is there anyway, I can suppress the Excel VBA compiler error.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…