VBA 检查模块中是否有某个函数

Function FindProcedures(ByRef wb As Workbook, ByVal Proc As String) As Boolean
    On Error GoTo ExitFunction
   
    Dim VBComp
    Dim CodeMod
    Dim LineNum As Long
    Dim ProcKind
   
    For Each VBComp In wb.VBProject.VBComponents
        If VBComp.Name = "模块1" Then
       
            With VBComp.CodeModule
           
                For N = 1 To .CountOfLines
                    s = .Lines(N, 1)
                    If InStr(s, Proc) > 0 Then
                        FindProcedures = True
                        Exit Function
                    End If
                   
                Next
            End With
       
        End If
    Next
   
    Exit Function

原文地址:https://www.cnblogs.com/lbnnbs/p/4784890.html