|
楼主 |
发表于 2024-3-14 10:51
|
显示全部楼层
目前测试完美,所有模块中的过程和函数都没问题。
- Sub test()
- Debug.Print ExistsOrNot("Sheet1.test")
- Debug.Print ExistsOrNot("test_aaa")
- Debug.Print ExistsOrNot("ExistsOrNot")
- Debug.Print ExistsOrNot("classfun", New Class1) '或者New userform1,New不能省略
- End Sub
- Function ExistsOrNot(processFullname, Optional Others)
- On Error Resume Next
- If IsMissing(Others) Then
- Run processFullname, Application, Modules, Workbooks, Sheets, Array(1, 2)
- If Err.Number = 450 Then
- ExistsOrNot = "Yes"
- ElseIf Err.Number = "1004" Then
- ExistsOrNot = "No"
- End If
- Else
- Dim obj As Object
- Set obj = Others
- CallByName obj, processFullname, VbMethod, Application, Modules, Workbooks, Sheets, Array(1, 2)
- If Err.Number = 450 Then
- ExistsOrNot = "Yes"
- ElseIf Err.Number = "438" Then
- ExistsOrNot = "No"
- End If
- End If
- End Function
复制代码 |
|