Michael
Thu Jul 28 21:36:17 CDT 2005
On Thu, 28 Jul 2005 09:15:52 -0700, "Ed" <ed_millis@NO_SPAM.yahoo.com>
wrote in microsoft.public.word.vba.general:
First a few things to your posting style:
1) Don't change the subject when you continue a thread; you might
never get a response.
2) Don't top-post when the previous contributor bottom-posted
(the preferred method).
3) Remove the signature of the previous posts.
4) Snip unnessesary line from previous posts.
>Michael: I get a "Sub or Function not defined" error on:
> lngLine = lngLine + .ProcCountLines(.ProcOfLine(lngLine,
>vbext_pk_Proc), vbext_pk_Proc)
>The offending item seems to be .ProcCountLines (at least, that's what gives
>the error on mouse-over when the line is highlighted yellow).
>I have the reference to VBA Extensibility 5.3 set. What else might I be
>missing?
[snip]
I hope you unwrapped the lines properly in case they got wrapped at your
end - they left here unwrapped and showed as such in my newsreader. Lines
which start in position 1 have been accidentally wrapped. All code below
starts in position 3 (plus indents).
I ran the macro in MS Word, Excel, and Access. There was a problem in
Excel with protected projects and apparently it needed the Application.
qualifier for the VBE.Projects object, so here is my amended code:
Sub CountMacros()
Dim objVBProj As VBProject
Dim objVBComps As VBComponents
Dim objVBComp As VBComponent
Dim objVBMod As CodeModule
Dim lngLine As Long
For Each objVBProj In Application.VBE.VBProjects
Debug.Print "Project: " & objVBProj.Name
If objVBProj.Protection = vbext_pp_none Then
Set objVBComps = objVBProj.VBComponents
For Each objVBComp In objVBComps
Debug.Print " Component: " & objVBComp.Name
Set objVBMod = objVBComp.CodeModule
With objVBMod
lngLine = .CountOfDeclarationLines + 1
Do Until lngLine >= .CountOfLines
Debug.Print " Procedure: " & .ProcOfLine(lngLine, vbext_pk_Proc)
lngLine = lngLine + .ProcCountLines(.ProcOfLine(lngLine, vbext_pk_Proc), vbext_pk_Proc)
Loop
End With
Next objVBComp
Else
Debug.Print " is protected."
End If
Next objVBProj
End Sub
--
Michael Bednarek
http://mbednarek.com/ "POST NO BILLS"