Access VBA: Is it possible to reset error handling

前端 未结 5 1848
慢半拍i
慢半拍i 2021-02-19 04:59

I am using in the first part of my program

on error go to start

Suppose in my second part I am again using

on error resume next

This second erro

5条回答
  •  你的背包
    2021-02-19 05:43

    It is nearly always better to avoid errors, rather than handling them. For example:

    Set objexcel = CreateObject("excel.Application")
    objexcel.Visible = True
    
    'On Error GoTo Openwb '
    'wbExists = False '
    
    If Dir("C:\REPORT3.xls") = "" Then
        objexcel.Workbooks.Add
        Set wbexcel = objexcel.ActiveWorkbook
        Set objSht = wbexcel.Worksheets("Sheet1")
    Else
        Set wbexcel = objexcel.Workbooks.Open("C:\REPORT3.xls")
        Set objSht = wbexcel.Worksheets("Sheet1")
    End If
    
    objSht.Activate
    'wbExists = True '
    

提交回复
热议问题