VBA + Excel + Try Catch

后端 未结 2 681
[愿得一人]
[愿得一人] 2021-01-01 11:17

In VBA, I\'m doing a simple script that records a version of a spreadsheet being used.

Private Sub Workbook_Open()
    version = \"1.0\"

    Set objHTTP = C         


        
2条回答
  •  盖世英雄少女心
    2021-01-01 11:33

    Something like this:

    Try
        ...
    Catch (Exception e)
        ...
    End Try
    

    Might look like this in VBA:

    ' The "Try" part
    On Error Resume Next
    ...
    On Error GoTo 0
    ' The "Catch" part
    If Err.Number <> 0 Then
    ...
    End If
    

    However, this form may not be following best practices.

提交回复
热议问题