Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Macro call, one workbook to another

Hi -
I have two workbooks in an application.
Book "One" opens before "Two". (a macro
does this.)
There are functions and subs in general modules
in book one, that I want to run from the Open
event in book two.

I don't want to have to copy the code and have it
be in two 'places.

Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)

I tried to modify the above application.run example from
the help section. The line below was a flat out guess.
Artemaint is the module containing the zpend_qtyf function
which returns an integer.

' line below is to be part of a sub executing from the
' booktwo.xls open event.

PendQty = Application.Run("bookone.xls(artemaint)!zpend_qtyf ")

If it's possible, please provide an example of the
correct syntax. I looked at the help for "Call" and
it said nothing about what I'd like.

The problem will go away when booktwo becomes an add-in
for bookone, but I'm not there yet.

As I write this, I'm heading into Walkenbach's book, but I'm not
optimistic about finding a reference quickly.
Thanks much.
--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macro call, one workbook to another

Look under global macros.

"Neal Zimm" wrote:

Hi -
I have two workbooks in an application.
Book "One" opens before "Two". (a macro
does this.)
There are functions and subs in general modules
in book one, that I want to run from the Open
event in book two.

I don't want to have to copy the code and have it
be in two 'places.

Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)

I tried to modify the above application.run example from
the help section. The line below was a flat out guess.
Artemaint is the module containing the zpend_qtyf function
which returns an integer.

' line below is to be part of a sub executing from the
' booktwo.xls open event.

PendQty = Application.Run("bookone.xls(artemaint)!zpend_qtyf ")

If it's possible, please provide an example of the
correct syntax. I looked at the help for "Call" and
it said nothing about what I'd like.

The problem will go away when booktwo becomes an add-in
for bookone, but I'm not there yet.

As I write this, I'm heading into Walkenbach's book, but I'm not
optimistic about finding a reference quickly.
Thanks much.
--
Neal Z

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default Macro call, one workbook to another

You don't need the module name, all you need is

PendQty = Application.Run("'bookone.xls'!zpend_qtyf")

This does assume that zpend_qtyf is a function, not a sub, otherwise nothing
will be returned into PenQty.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Neal Zimm" wrote in message
...
Hi -
I have two workbooks in an application.
Book "One" opens before "Two". (a macro
does this.)
There are functions and subs in general modules
in book one, that I want to run from the Open
event in book two.

I don't want to have to copy the code and have it
be in two 'places.

Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)

I tried to modify the above application.run example from
the help section. The line below was a flat out guess.
Artemaint is the module containing the zpend_qtyf function
which returns an integer.

' line below is to be part of a sub executing from the
' booktwo.xls open event.

PendQty = Application.Run("bookone.xls(artemaint)!zpend_qtyf ")

If it's possible, please provide an example of the
correct syntax. I looked at the help for "Call" and
it said nothing about what I'd like.

The problem will go away when booktwo becomes an add-in
for bookone, but I'm not there yet.

As I write this, I'm heading into Walkenbach's book, but I'm not
optimistic about finding a reference quickly.
Thanks much.
--
Neal Z



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro call, one workbook to another

PendQty = Application.Run("bookone.xls!artemaint.zpend_qtyf" )

but if there is only one zpend_qtfy in bookone, then you don't need the
module name

PendQty = Application.Run("bookone.xls!zpend_qtyf")

--
Regards,
Tom Ogilvy



"Neal Zimm" wrote in message
...
Hi -
I have two workbooks in an application.
Book "One" opens before "Two". (a macro
does this.)
There are functions and subs in general modules
in book one, that I want to run from the Open
event in book two.

I don't want to have to copy the code and have it
be in two 'places.

Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)

I tried to modify the above application.run example from
the help section. The line below was a flat out guess.
Artemaint is the module containing the zpend_qtyf function
which returns an integer.

' line below is to be part of a sub executing from the
' booktwo.xls open event.

PendQty = Application.Run("bookone.xls(artemaint)!zpend_qtyf ")

If it's possible, please provide an example of the
correct syntax. I looked at the help for "Call" and
it said nothing about what I'd like.

The problem will go away when booktwo becomes an add-in
for bookone, but I'm not there yet.

As I write this, I'm heading into Walkenbach's book, but I'm not
optimistic about finding a reference quickly.
Thanks much.
--
Neal Z



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Macro call, one workbook to another

Thanks Whiz, will do.
--
Neal Z


"JLGWhiz" wrote:

Look under global macros.

"Neal Zimm" wrote:

Hi -
I have two workbooks in an application.
Book "One" opens before "Two". (a macro
does this.)
There are functions and subs in general modules
in book one, that I want to run from the Open
event in book two.

I don't want to have to copy the code and have it
be in two 'places.

Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)

I tried to modify the above application.run example from
the help section. The line below was a flat out guess.
Artemaint is the module containing the zpend_qtyf function
which returns an integer.

' line below is to be part of a sub executing from the
' booktwo.xls open event.

PendQty = Application.Run("bookone.xls(artemaint)!zpend_qtyf ")

If it's possible, please provide an example of the
correct syntax. I looked at the help for "Call" and
it said nothing about what I'd like.

The problem will go away when booktwo becomes an add-in
for bookone, but I'm not there yet.

As I write this, I'm heading into Walkenbach's book, but I'm not
optimistic about finding a reference quickly.
Thanks much.
--
Neal Z



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Macro call, one workbook to another

Thanks Bob, will give it a try.

--
Neal Z


"Bob Phillips" wrote:

You don't need the module name, all you need is

PendQty = Application.Run("'bookone.xls'!zpend_qtyf")

This does assume that zpend_qtyf is a function, not a sub, otherwise nothing
will be returned into PenQty.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Neal Zimm" wrote in message
...
Hi -
I have two workbooks in an application.
Book "One" opens before "Two". (a macro
does this.)
There are functions and subs in general modules
in book one, that I want to run from the Open
event in book two.

I don't want to have to copy the code and have it
be in two 'places.

Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)

I tried to modify the above application.run example from
the help section. The line below was a flat out guess.
Artemaint is the module containing the zpend_qtyf function
which returns an integer.

' line below is to be part of a sub executing from the
' booktwo.xls open event.

PendQty = Application.Run("bookone.xls(artemaint)!zpend_qtyf ")

If it's possible, please provide an example of the
correct syntax. I looked at the help for "Call" and
it said nothing about what I'd like.

The problem will go away when booktwo becomes an add-in
for bookone, but I'm not there yet.

As I write this, I'm heading into Walkenbach's book, but I'm not
optimistic about finding a reference quickly.
Thanks much.
--
Neal Z




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Macro call, one workbook to another

Dear Tom,
Again, many thanks. I thought Bob's answer might be a little "short".
will try yours out asap. I'd love to give your replay the green useful
check, but I'm not seeing it anymore on the reply screen I get, I'm not sure
why.

--
Neal Z


"Tom Ogilvy" wrote:

PendQty = Application.Run("bookone.xls!artemaint.zpend_qtyf" )

but if there is only one zpend_qtfy in bookone, then you don't need the
module name

PendQty = Application.Run("bookone.xls!zpend_qtyf")

--
Regards,
Tom Ogilvy



"Neal Zimm" wrote in message
...
Hi -
I have two workbooks in an application.
Book "One" opens before "Two". (a macro
does this.)
There are functions and subs in general modules
in book one, that I want to run from the Open
event in book two.

I don't want to have to copy the code and have it
be in two 'places.

Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)

I tried to modify the above application.run example from
the help section. The line below was a flat out guess.
Artemaint is the module containing the zpend_qtyf function
which returns an integer.

' line below is to be part of a sub executing from the
' booktwo.xls open event.

PendQty = Application.Run("bookone.xls(artemaint)!zpend_qtyf ")

If it's possible, please provide an example of the
correct syntax. I looked at the help for "Call" and
it said nothing about what I'd like.

The problem will go away when booktwo becomes an add-in
for bookone, but I'm not there yet.

As I write this, I'm heading into Walkenbach's book, but I'm not
optimistic about finding a reference quickly.
Thanks much.
--
Neal Z




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro call, one workbook to another

Bob's answer was pretty much the same as my second suggestion.

While he didn't need it for the sample names you provided (no space in the
name), he did raise a good point by including the single quotes which are
necessary if there is a space in the workbook name.

so if the workbook name was "Book One.xls" then

PendQty = Application.Run("'book one.xls'!artemaint.zpend_qtyf")

as a restatement.

--
Regards,
Tom Ogilvy


"Neal Zimm" wrote in message
...
Dear Tom,
Again, many thanks. I thought Bob's answer might be a little "short".
will try yours out asap. I'd love to give your replay the green useful
check, but I'm not seeing it anymore on the reply screen I get, I'm not
sure
why.

--
Neal Z


"Tom Ogilvy" wrote:

PendQty = Application.Run("bookone.xls!artemaint.zpend_qtyf" )

but if there is only one zpend_qtfy in bookone, then you don't need the
module name

PendQty = Application.Run("bookone.xls!zpend_qtyf")

--
Regards,
Tom Ogilvy



"Neal Zimm" wrote in message
...
Hi -
I have two workbooks in an application.
Book "One" opens before "Two". (a macro
does this.)
There are functions and subs in general modules
in book one, that I want to run from the Open
event in book two.

I don't want to have to copy the code and have it
be in two 'places.

Application.Run("MYCUSTOM.XLM!My_Func_Sum", 1, 5)

I tried to modify the above application.run example from
the help section. The line below was a flat out guess.
Artemaint is the module containing the zpend_qtyf function
which returns an integer.

' line below is to be part of a sub executing from the
' booktwo.xls open event.

PendQty = Application.Run("bookone.xls(artemaint)!zpend_qtyf ")

If it's possible, please provide an example of the
correct syntax. I looked at the help for "Call" and
it said nothing about what I'd like.

The problem will go away when booktwo becomes an add-in
for bookone, but I'm not there yet.

As I write this, I'm heading into Walkenbach's book, but I'm not
optimistic about finding a reference quickly.
Thanks much.
--
Neal Z






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
How to call macro from other workbook ppyxl[_10_] Excel Programming 8 July 12th 06 04:33 PM
Call Macro from another WorkBook? Steven M. Britton[_2_] Excel Programming 6 June 10th 05 04:33 PM
How can I call a macro in another workbook? ned Excel Programming 4 May 31st 04 09:50 PM
Open Another Workbook and Call Macro Bill Oertell[_2_] Excel Programming 1 January 20th 04 04:29 AM
Call a macro in other workbook Davwe[_4_] Excel Programming 2 December 17th 03 08:14 PM


All times are GMT +1. The time now is 01:24 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"