对要try-catch的语句On Error GoTo errorHandle,然后errorHandle里对err(.number)进行判断,对不同的error进行不同的error处理。
Sub asdasd()
Set li2 = New Collection
Set dic1 = CreateObject("scripting.dictionary")
dic1.Add 1, 2
On Error GoTo errorHandle
li2.Remove ("noExistsKey")
errorHandle:
Set er = Err
erNum = er.Number '5
On Error GoTo e2 'raise error here,put this code to other function ,run ok
dic1.Remove ("1") 'runtimeerror 32811
e2:
Set er = Err
End Sub