#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro Help

Is it possible to programatically gain access to a list of
macros available in an Excel workbook? I need to populate
a combo box with all available macro names. thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Macro Help

Matt,

You'll need to add a reference to 'Microsoft Visual Basic for Applications
Extensibility' (VBA: Tools | References)

Private Sub CommandButton1_Click()
Dim vbc As VBComponent, i As Long, j As Long, strProcName As String,
strTemp As String

For Each vbc In ThisWorkbook.VBProject.VBComponents
If vbc.Type = vbext_ct_Document Or vbc.Type = vbext_ct_StdModule
Then
With vbc.CodeModule
i = .CountOfDeclarationLines + 1
Do Until i = .CountOfLines + 1
strProcName = .ProcOfLine(i, vbext_pk_Proc)
j = i: strTemp = .Lines(j, 1)
Do Until Left(strTemp, 4) = "Sub " Or Left(strTemp, 9) =
"Function "
j = j + 1
strTemp = .Lines(j, 1)
Loop
i = i + .ProcCountLines(strProcName, vbext_pk_Proc)
ComboBox1.AddItem vbc.Name & ": " & Mid(strTemp, 1,
InStr(1, strTemp, "(") - 1)
Loop
End With
End If
Next
End Sub


Rob


"Matt" wrote in message
...
Is it possible to programatically gain access to a list of
macros available in an Excel workbook? I need to populate
a combo box with all available macro names. thanks



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 06:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"