Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run excel macro on one xls from another xls

I need to call a macro Macro1 written in A.xls from another macro Macro2
written in b.xls.

The file name "a.xls" is actually stored in column A on of b.xls, thus is in
a variable. Macro name Macro1 is defined and static.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Run excel macro on one xls from another xls

Application.Run ("A.xls'!Macro1")

A.xls needs to be open first.
Mike F
"Kishore Shenoi" <Kishore wrote in message
...
I need to call a macro Macro1 written in A.xls from another macro Macro2
written in b.xls.

The file name "a.xls" is actually stored in column A on of b.xls, thus is
in
a variable. Macro name Macro1 is defined and static.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Run excel macro on one xls from another xls

Hi Kishore Shenoi,

In Macro2 use the command
Application.Run "A.xls!Macro1"

If the name of the macro (say Macro1) is stored on the active sheet in
B.xls, say in A1, you can read it into a VBA variable (say MName), append the
workbook name and then run it like this:

MName = Range("A1")
MName = "A.xls!" & MName
Application.Run MName

Hope this helps


--
Gerd


"Kishore Shenoi" wrote:

I need to call a macro Macro1 written in A.xls from another macro Macro2
written in b.xls.

The file name "a.xls" is actually stored in column A on of b.xls, thus is in
a variable. Macro name Macro1 is defined and static.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Run excel macro on one xls from another xls

Application.Run ("'A.xls'!Macro1")

Sorry, I left out the first single quote.

Mike F

"Mike Fogleman" wrote in message
m...
Application.Run ("A.xls'!Macro1")

A.xls needs to be open first.
Mike F
"Kishore Shenoi" <Kishore wrote in
message ...
I need to call a macro Macro1 written in A.xls from another macro Macro2
written in b.xls.

The file name "a.xls" is actually stored in column A on of b.xls, thus is
in
a variable. Macro name Macro1 is defined and static.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Run excel macro on one xls from another xls

Here is an example from one of my workbooks if the workbook with the macro
to run is not open, but is in the same folder and is password protected to
open it...

Dim cdir As String
Dim wb As Workbook

For Each wb In Workbooks
If wb.name = "NCP C4-1 Tracking.xls" Then
MsgBox ("NCP C4-1 Tracking.xls is already open.")
Exit Sub
End If
Next wb
cdir = ActiveWorkbook.Path
Workbooks.Open cdir & "\NCP C4-1 Tracking.xls", password:="NCP"
Application.Run ("'NCP C4-1 Tracking.xls'!RunUpdate")

Substitute your workbook name, macro name, and password as needed.

Mike F
"Mike Fogleman" wrote in message
m...
Application.Run ("'A.xls'!Macro1")

Sorry, I left out the first single quote.

Mike F

"Mike Fogleman" wrote in message
m...
Application.Run ("A.xls'!Macro1")

A.xls needs to be open first.
Mike F
"Kishore Shenoi" <Kishore wrote in
message ...
I need to call a macro Macro1 written in A.xls from another macro Macro2
written in b.xls.

The file name "a.xls" is actually stored in column A on of b.xls, thus
is in
a variable. Macro name Macro1 is defined and static.







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 Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Call macro stored in Excel workbook from Outlook's macro Gvaram Excel Programming 0 October 4th 06 05:47 PM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
translate lotus 1-2-3 macro into excel macro using excel 2000 krutledge0209 Excel Programming 1 November 2nd 04 05:50 PM


All times are GMT +1. The time now is 08:35 AM.

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

About Us

"It's about Microsoft Excel"