View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
MSP77079[_7_] MSP77079[_7_] is offline
external usenet poster
 
Posts: 1
Default List macros for user to select...

ali, the macro below will debug.print a list of macros and which module
they are found in. You can use this list to populate a combobox (I
assume that you already know how to do that, right?)


Sub CreateListofMacros()
Attribute Macro2.VB_Description = "12/28/03 by Pete"
Attribute Macro2.VB_ProcData.VB_Invoke_Func = " \n14"
'
' Macro2 Macro
'
Dim startLine As Long, LastLine As Long, startcol As Long
Set thisProject = Application.VBE.ActiveVBProject

LineCount = Application.VBE.CodePanes(2).CodeModule.CountOfLin es

'thiscomponent =
Application.VBE.ActiveVBProject.VBComponents(6).Na me

For Each Pane In Application.VBE.CodePanes
startLine = 1
startcol = 1
LastLine = Pane.CodeModule.CountOfLines
SubHere = Pane.CodeModule.Find("Sub", startLine, startcol,
2000, 1, False, False)
Do While startLine < LastLine
thisSub = Pane.CodeModule.procofline(startLine, 1)
If thisSub < thatSub Then
Debug.Print thisSub & " is found in " &
Pane.CodeModule.Name
thatSub = thisSub
End If
'On Error Resume Next

startLine = startLine + 1
Loop
Next Pane

'VBAProject.Test.CreateListofMacros

End Sub


---
Message posted from http://www.ExcelForum.com/