Reference Object on User Form in separate Workbook

Maryz

Board Regular
Joined
Dec 10, 2002
Messages
197
I know how to run a macro that resides in a module in another workbook.

Application.Run "'MacroSource.xls'!Macro1"

What I would like to do is control an object that resides on a user form in another workbook and I’m having problems with the statement. For example, I like to have a user press a command button on UserForm1 which resides in Book1.xls and change the caption on Label1 of the same form with Macro1 from a module of another book called MacroSource.xls. The statement above will allow me to execute Macro1 from Book1.xls. Where I need help is the Macro1 procedure.

Sub Macro1()
Book1.xls UserForm1.Label1 = "Hello"
End Sub

How do I properly combine the above statement to control Label1 on UserForm1 in Book1.xls from Macro1 which resides in a module in MacroSource.xls?
 
Hello,

Just out of curiosity, aren't references saved with the workbook? I've always thought that if you set the reference when developing, and save the workbook, that the reference remains. As long as the user has access to the path where the referenced file is, it should work...

Having said that, I have noticied an issue there. If you use a different Excel version, you can run in to issues. We have a user on 97 running on Win 2000, and the VBA Extensibility Pack shows up under a slightly different name than on my Office '03 on Win XP.

As I say, just curious...
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top