Refer to another module

I have a small problem with a macro. I have two different moduls in my code.

In module1 i have the code for some buttons and so and in module2 i have the

code for what happens if i press the buttons. However my code has trouble

finding the different modules and I need help on how to write this properly.

Code in module1:

Sub Create_Menu()

Dim MyBar As CommandBar

Dim MyPopup As CommandBarPopup

Dim button1 As CommandBarButton

.....

Set button1 = .Controls.Add(Type:=msoControlButton)

With button1

.Caption = "Button!"

.BeginGroup = True

.OnAction = "button1_Click"

and in modul2:

Sub button1_Click()

Dim objChart As ChartObject

Now I need help with how to refer to the sub. My code is quite messy if i

have to have it in the same module so it would be prefect it that was

possible. Thanks very much in advance!

[926 byte] By [AndersBank] at [2007-12-23]
# 1

try this,

.OnAction = "'" & ThisWorkbook.Name & "'!button1_Click"

also make your modules methods public like this

Public Sub button1_Click()

DerekSmyth at 2007-8-31 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...