Here is my code,
For Each pj In wdApp.Application.VBE.VBProjects
x = pj.FileName
y = pj.Protection
If x <> "" Then
If y <> "1" Then
For Each vbcomp In pj.VBComponents
For i = 1 To vbcomp.CodeModule.CountOfLines
newMacro = vbcomp.CodeModule.ProcOfLine(Line:=i, prockind:=vbext_pk_Proc)
If curMacro <> newMacro Then
curMacro = newMacro
cboMacros.AddItem (curMacro)
Debug.Print curMacro
Else: newMacro = Null
End If
Next
Next
End If
Selection.InsertAfter vbCr
End If
x = ""
Next
Selection.Collapse wdCollapseEnd
End Sub
the issue is, I can return the name of all macros in an associated file, but it is horribly inefficient. It takes @2 minutes for 85 macro names. This is because the program reads every line of every module (CountOfLines). I was just hoping there may be some magic that could be performed in my else statement. If the current macro is the same as newmacro then just skip to when they are different. I am not sure if this is possible? If not, is there a better method to use that CountOfLines?