ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run macro in another workbook (https://www.excelbanter.com/excel-programming/322640-run-macro-another-workbook.html)

konpego

Run macro in another workbook
 
Hi,

I have two WBs open and are updating/merging data from one to the other. I
want to run a macro in one WB to create data on a specific WS. The results
shall be copied from the WB into the other.
To generate the data there is a pushbutton on one WS (connected to a macro).
The resulting data is gathered on another WS, that is to be copied to the
other WB.

How can I execute a macro in another WB (in VB)?

/konpego

Tom Ogilvy

Run macro in another workbook
 
If you don't have reference from the calling workbook to the workbook with
the macro, you would use application.Run

application.Run "OtherWorkbookName.xls!Macro1"

--
Regards,
Tom Ogilvy


"konpego" wrote in message
...
Hi,

I have two WBs open and are updating/merging data from one to the other. I
want to run a macro in one WB to create data on a specific WS. The results
shall be copied from the WB into the other.
To generate the data there is a pushbutton on one WS (connected to a

macro).
The resulting data is gathered on another WS, that is to be copied to the
other WB.

How can I execute a macro in another WB (in VB)?

/konpego




konpego

Run macro in another workbook
 
I have tried this but it seems to be some problem.....

Are there any restrictions on the WB name?
My name contains blanks, minus-sign, parenthesis.
Is this allowed?

Best Regards

konpego

"Tom Ogilvy" wrote:

If you don't have reference from the calling workbook to the workbook with
the macro, you would use application.Run

application.Run "OtherWorkbookName.xls!Macro1"

--
Regards,
Tom Ogilvy


"konpego" wrote in message
...
Hi,

I have two WBs open and are updating/merging data from one to the other. I
want to run a macro in one WB to create data on a specific WS. The results
shall be copied from the WB into the other.
To generate the data there is a pushbutton on one WS (connected to a

macro).
The resulting data is gathered on another WS, that is to be copied to the
other WB.

How can I execute a macro in another WB (in VB)?

/konpego





Chip Pearson

Run macro in another workbook
 
If the name contains blanks, you need to enclose the file name
within single quotes. E.g.,

Application.Run "'Other Workbook Name.xls'!MacroName"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"konpego" wrote in message
...
I have tried this but it seems to be some problem.....

Are there any restrictions on the WB name?
My name contains blanks, minus-sign, parenthesis.
Is this allowed?

Best Regards

konpego

"Tom Ogilvy" wrote:

If you don't have reference from the calling workbook to the
workbook with
the macro, you would use application.Run

application.Run "OtherWorkbookName.xls!Macro1"

--
Regards,
Tom Ogilvy


"konpego" wrote in message
...
Hi,

I have two WBs open and are updating/merging data from one
to the other. I
want to run a macro in one WB to create data on a specific
WS. The results
shall be copied from the WB into the other.
To generate the data there is a pushbutton on one WS
(connected to a

macro).
The resulting data is gathered on another WS, that is to be
copied to the
other WB.

How can I execute a macro in another WB (in VB)?

/konpego







Tom Ogilvy

Run macro in another workbook
 
Sub RunOrganize()
Application.Run "'My - Test - (b) & ook.xls'!OrganizeData"
End Sub

Enclose the name in single quotes.

The above worked for me.

--
Regards,
Tom Ogilvy



"konpego" wrote in message
...
I have tried this but it seems to be some problem.....

Are there any restrictions on the WB name?
My name contains blanks, minus-sign, parenthesis.
Is this allowed?

Best Regards

konpego

"Tom Ogilvy" wrote:

If you don't have reference from the calling workbook to the workbook

with
the macro, you would use application.Run

application.Run "OtherWorkbookName.xls!Macro1"

--
Regards,
Tom Ogilvy


"konpego" wrote in message
...
Hi,

I have two WBs open and are updating/merging data from one to the

other. I
want to run a macro in one WB to create data on a specific WS. The

results
shall be copied from the WB into the other.
To generate the data there is a pushbutton on one WS (connected to a

macro).
The resulting data is gathered on another WS, that is to be copied to

the
other WB.

How can I execute a macro in another WB (in VB)?

/konpego







Tom Ogilvy

Run macro in another workbook
 
Just to add:

Single quotes is the answer for you as Chip stated, but blanks alone don't
require them. This ran fine for me

Sub RunOrganize()
Application.Run "My - Test - book.xls!OrganizeData"
End Sub

when I changed the name to My - Text - (b) & ook.xls, then I needed single
quotes.

--
Regards,
Tom Ogilvy

"Chip Pearson" wrote in message
...
If the name contains blanks, you need to enclose the file name
within single quotes. E.g.,

Application.Run "'Other Workbook Name.xls'!MacroName"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"konpego" wrote in message
...
I have tried this but it seems to be some problem.....

Are there any restrictions on the WB name?
My name contains blanks, minus-sign, parenthesis.
Is this allowed?

Best Regards

konpego

"Tom Ogilvy" wrote:

If you don't have reference from the calling workbook to the
workbook with
the macro, you would use application.Run

application.Run "OtherWorkbookName.xls!Macro1"

--
Regards,
Tom Ogilvy


"konpego" wrote in message
...
Hi,

I have two WBs open and are updating/merging data from one
to the other. I
want to run a macro in one WB to create data on a specific
WS. The results
shall be copied from the WB into the other.
To generate the data there is a pushbutton on one WS
(connected to a
macro).
The resulting data is gathered on another WS, that is to be
copied to the
other WB.

How can I execute a macro in another WB (in VB)?

/konpego









All times are GMT +1. The time now is 04:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com