Consulting

Results 1 to 3 of 3

Thread: macro listbox

  1. #1
    VBAX Mentor
    Joined
    Jun 2005
    Posts
    374
    Location

    macro listbox

    hello
    is there a way through vba to get the list of macros in a workbook.
    i mean the list i get when i predd alt+f8.
    maybe by using :
    [VBA] Application.Dialogs[/VBA]
    thanks
    moshe

  2. #2
    VBAX Expert
    Joined
    Jul 2004
    Location
    Wilmington, DE
    Posts
    600
    Location
    Moshe,

    This is the same question you asked in:
    http://www.vbaexpress.com/forum/showthread.php?t=6560

    Patrick

  3. #3
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    Hey Moshe,

    I found this at http://www.cpearson.com/excel/vbe.htm and I modified it a little for more functionality. Tell me if it works

    [VBA]Option Explicit

    Sub ListProcedures()
    Dim VBComp As VBComponent
    Dim VBCodeMod As CodeModule
    Dim StartLine As Long
    Dim Msg As String

    For Each VBComp In ThisWorkbook.VBProject.VBComponents
    Set VBCodeMod = ThisWorkbook.VBProject.VBComponents(VBComp.Name).CodeModule
    Msg = Msg & VBComp.Name & vbCrLf
    With VBCodeMod
    StartLine = .CountOfDeclarationLines + 1
    Do Until StartLine >= .CountOfLines
    Msg = Msg & "-" & .ProcOfLine(StartLine, vbext_pk_Proc) & Chr(13)
    StartLine = StartLine + .ProcCountLines(.ProcOfLine(StartLine, vbext_pk_Proc), vbext_pk_Proc)
    Loop
    End With
    Msg = Msg & vbCrLf
    Next VBComp
    MsgBox Msg
    End Sub[/VBA]




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •