is it possible to create a drop down menu in excel97 instead of using button to run the macro that w


Posted by newby on October 24, 2000 5:11 AM

tq

Posted by Ivan Moala on October 25, 2000 3:18 AM

yes it is possible.....have a look @ code;
Note:

using combobox from Control toolbox = ActiveX
object.
Need to reference the VBA applications extensibility file
in your project.


Option Explicit
'==========================================================================================
'= =
'= Module: Sheet1 =
'= Type: Document Class Module =
'= =
'= Developer: Ivan F Moala =
'= Date: 25-Oct-2000 =
'= =
'= Description: Requires reference to Microsoft VBA for applications extensibilty =
'= =
'= Subprocedures: ComboBox1_Click =
'= ComboBox1_DropButtonClick =
'= Functions: None =
'= Properties: None =
'= DLL Declares: None =
'= =
'==========================================================================================


Private Sub ComboBox1_Click()
Dim Q As Integer
Q = MsgBox("Run " & ComboBox1.Text & " macro ??", vbYesNo)
If Q = vbYes Then
Application.Run ComboBox1.Text
End If
End Sub

Private Sub ComboBox1_DropButtonClick()
Dim VBCodeMod As CodeModule
Dim StartLine As Long
Dim ProcName As String
Dim VBComp

ComboBox1.Clear

For Each VBComp In ThisWorkbook.VBProject.VBComponents

Set VBCodeMod = ThisWorkbook.VBProject.VBComponents(VBComp.Name).CodeModule

If VBComp.Type = vbext_ct_StdModule Then

With VBCodeMod
StartLine = .CountOfDeclarationLines + 1
Do Until StartLine >= .CountOfLines
ComboBox1.AddItem .ProcOfLine(StartLine, vbext_pk_Proc)
StartLine = StartLine + .ProcCountLines(.ProcOfLine(StartLine, _
vbext_pk_Proc), vbext_pk_Proc)
Loop
End With
End If
Next VBComp

End Sub

Ivan

Posted by newby on October 25, 2000 4:27 AM

thanks Ivan. u r very cool..but your code is too difficult 4 me understand..anyway..thanks a bunch

Posted by Ivan Moala on October 28, 2000 1:36 PM

Re: thanks Ivan. u r very cool..but your code is too difficult 4 me understand..anyway..thanks a bunch


Newby

If you are at odds to get this working then email
me and I'll send an example.

Ivan



Posted by newby on October 31, 2000 3:18 AM

Thanks Ivan. Check your email.Hope you can help me.Bye