Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

CommandButton Link to Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KMassey1976 - 22 Mar 2006 01:55 GMT
How do you link a Macro to a CommandButton.

Right now when I click on the button in design mode it references a
macro on the worksheet I am working on and it is trying to reference
another Macro.  The macro is stored in a different file in another
directory.  What is the file path to reference a Macro somewhere else?

So far my code in the commandbutton looks like this, but it doesn't do
anything when I click the button.  I am missing some part of the path
to find the Macro.  Can anyone help me?

Private Sub File_Updated_Click()

   Public Sub Fileupdate()
   
End Sub

Thank you for your help!
Kristina
awaters@linnhoffmarch.com - 22 Mar 2006 10:46 GMT
You can run a macro in another file using:

Excel.Run "<file>!<macro>"

where you replace <file> with the filename and <macro> with the macro
name.

However, I think the file already needs to be open in Excel, so you
will probably need to do that in your code also.
Gerencsér Gábor - 22 Mar 2006 21:27 GMT
The easiest thing you can do is to
(a) create an object instead of a button within the file you have the macro
stored. This can be a rectangle, that looks like a CommandButton, but it is
actually a rectangle object.
(b) you assign the required macro to this object
(c) you then copy and paste the object into the file you want to start the
macro from

In case the file with the macro is not open when the user hits the pseudo
'button', excel will open the file for the user to run the macro.
Hope this is an option, at least it works fine for me in '97.

Gabor

"KMassey1976" <kristinadoyle@hotmail.com> az alábbiakat írta a következo
hírüzenetben: 1142988926.998372.42540@i39g2000cwa.googlegroups.com...
> How do you link a Macro to a CommandButton.
>
[quoted text clipped - 15 lines]
> Thank you for your help!
> Kristina
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.