Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort | Excel Worksheet Functions | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
Call macro stored in Excel workbook from Outlook's macro | Excel Programming | |||
Need syntax for RUNning a Word macro with an argument, called from an Excel macro | Excel Programming | |||
translate lotus 1-2-3 macro into excel macro using excel 2000 | Excel Programming |