Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Calling macros from a VB app

I currently run macros from a VB application, and my code within
the app looks something like:

ShellExecute(0&, vbNullString, "excel", q & file_to_operate_on & q & q & file_macro_is_in & q, vbNullString, vbNormalFocus)

However, I wanted to ask, suppose file_macro_is_in has many macros defined
in it, and I want to execute only one particular one. Does Excel have any
command line arguments that would allow me to do this? For instance,
making something along the lines of the following possible:

ShellExecute(0&, vbNullString, "excel", q & file_to_operate_on & q & q & file_macro_is_in & q & "-mymacroname", vbNullString, vbNormalFocus)

Also, so that I don't ask too many questions that could probably be answered
by some reading, can anyone recommend a source for thorough documentation
on the Excel API + command line arguments to Excel? Thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Calling macros from a VB app

"shelling" an application this way probably isn't the
best route for you.

In VB
DIM XLapp as ExcelApplication
or
DIM XLapp as Object

then SET the variable to excel.application or, if the
variable is obkect, use the createobject method.

Now you've got a handle on the application you can open
any known wotkbook
DIM WB as Excel.Workbook
SET WB = XLapp.Workbooks.Open(wb_fullpath)

the WB variable can be an object or workbook. However,
you naw have a handle on the workbook.
To run a macro just call it, for example:-

XLApp.Run "Main", sControlDate, tsLog, Traders, Exports

the syntax is
.RUN proc name [,parameter 1][,parameter2][....]

This gives you absolute control over Excel.
Remeber to clean up...
WBClose False
XLApp.Quit
set WB = Nothing
set XLapp = Nothing

HTH
Patrick Molloy
Microsoft Excel MVP









-----Original Message-----
I currently run macros from a VB application, and my

code within
the app looks something like:

ShellExecute(0&, vbNullString, "excel", q &

file_to_operate_on & q & q & file_macro_is_in & q,
vbNullString, vbNormalFocus)

However, I wanted to ask, suppose file_macro_is_in has

many macros defined
in it, and I want to execute only one particular one.

Does Excel have any
command line arguments that would allow me to do this?

For instance,
making something along the lines of the following

possible:

ShellExecute(0&, vbNullString, "excel", q &

file_to_operate_on & q & q & file_macro_is_in & q & "-
mymacroname", vbNullString, vbNormalFocus)

Also, so that I don't ask too many questions that could

probably be answered
by some reading, can anyone recommend a source for

thorough documentation
on the Excel API + command line arguments to Excel?

Thank you.
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Calling macros from a VB app

Thank you for the response. I tried fitting the code
into my application but received a compilation error.
What library do I need to include to be able to use
objects of type "ExcelApplication"? Also, I am very new
to Excel programming, so I would be very grateful if
you could point me toward API documentation so that I
can read it versus troubling people on the forums
unnecessarily.

"Patrick Molloy" wrote:

"shelling" an application this way probably isn't the
best route for you.

In VB
DIM XLapp as ExcelApplication
or
DIM XLapp as Object

then SET the variable to excel.application or, if the
variable is obkect, use the createobject method.

Now you've got a handle on the application you can open
any known wotkbook
DIM WB as Excel.Workbook
SET WB = XLapp.Workbooks.Open(wb_fullpath)

the WB variable can be an object or workbook. However,
you naw have a handle on the workbook.
To run a macro just call it, for example:-

XLApp.Run "Main", sControlDate, tsLog, Traders, Exports

the syntax is
.RUN proc name [,parameter 1][,parameter2][....]

This gives you absolute control over Excel.
Remeber to clean up...
WBClose False
XLApp.Quit
set WB = Nothing
set XLapp = Nothing

HTH
Patrick Molloy
Microsoft Excel MVP









-----Original Message-----
I currently run macros from a VB application, and my

code within
the app looks something like:

ShellExecute(0&, vbNullString, "excel", q &

file_to_operate_on & q & q & file_macro_is_in & q,
vbNullString, vbNormalFocus)

However, I wanted to ask, suppose file_macro_is_in has

many macros defined
in it, and I want to execute only one particular one.

Does Excel have any
command line arguments that would allow me to do this?

For instance,
making something along the lines of the following

possible:

ShellExecute(0&, vbNullString, "excel", q &

file_to_operate_on & q & q & file_macro_is_in & q & "-
mymacroname", vbNullString, vbNormalFocus)

Also, so that I don't ask too many questions that could

probably be answered
by some reading, can anyone recommend a source for

thorough documentation
on the Excel API + command line arguments to Excel?

Thank you.
.


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
CALLING MACROS FROM A NEW WORKSHEET NSNR Excel Discussion (Misc queries) 4 February 1st 08 07:10 AM
calling macros from worksheet to another NSNR Excel Discussion (Misc queries) 3 October 27th 07 01:49 PM
Calling macros in another workbook Nick Wright Excel Worksheet Functions 1 January 12th 06 04:03 PM
Calling Macros from a list Anonymous[_3_] Excel Programming 1 November 21st 03 07:17 PM
Calling macros in another spreadsheet skimmer333 Excel Programming 0 September 30th 03 01:43 AM


All times are GMT +1. The time now is 06:42 PM.

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"