Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Only Explicit Call of Procedure in another workbook???

Hi,

I was trying to find out if the only way to call a macro in another workbook
is to explicitly use the filename and macro name:

ie: Application.Run ("Oil & Gas.xls!Refresh_Data")

or is there any way to use something like the following:

Application.Run ("""'"& ActiveWorkbook.Name & "'" & "!Refresh_Data" & """")
after I open the file with the code
--when I use this it doesn't recognize the passed variable

I am using a file search to return a list of files within a few directories
and all of these files have a macro named "Refresh_Data". My code will be
significantly shorter and easier to write if I can somehow pass the file
name/macro name from the file search and loop through them and not have to
write the same process explicitly using the filename over a hundred times.

Is it possible? Or do I have to write the longer procedure and create the
file open and run macro for each and every file?

The RefreshData codes are similair across all of these files, but each one
has some unique properties that prevent me from having one code that does the
update in the wbk that uses the file search.

Hoping someone can help me.

Thanks in advance,
Kohai
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Only Explicit Call of Procedure in another workbook???

I guess you can do it. I created a string variable to be the name of the
file and the macro name and passed that to Application.Run

MacroName = "'" & LArray(Y) & "'" & "!Refresh_Data"
Application.Run (MacroName)

Thanks to any who looked.

"kohai" wrote:

Hi,

I was trying to find out if the only way to call a macro in another workbook
is to explicitly use the filename and macro name:

ie: Application.Run ("Oil & Gas.xls!Refresh_Data")

or is there any way to use something like the following:

Application.Run ("""'"& ActiveWorkbook.Name & "'" & "!Refresh_Data" & """")
after I open the file with the code
--when I use this it doesn't recognize the passed variable

I am using a file search to return a list of files within a few directories
and all of these files have a macro named "Refresh_Data". My code will be
significantly shorter and easier to write if I can somehow pass the file
name/macro name from the file search and loop through them and not have to
write the same process explicitly using the filename over a hundred times.

Is it possible? Or do I have to write the longer procedure and create the
file open and run macro for each and every file?

The RefreshData codes are similair across all of these files, but each one
has some unique properties that prevent me from having one code that does the
update in the wbk that uses the file search.

Hoping someone can help me.

Thanks in advance,
Kohai

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
Call VBA procedure ilocated in another workbook [email protected] Excel Programming 1 February 26th 07 11:25 PM
procedure call BorisS Excel Programming 1 September 18th 06 07:16 AM
Call a procedure in the workbook from a worksheet Selina Excel Programming 3 April 21st 05 01:04 PM
Where else to look for procedure call Lulu Excel Programming 2 November 24th 04 02:14 AM
Send menu call to explicit Sub Stuart[_5_] Excel Programming 6 September 29th 03 12:44 AM


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