ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DOS Command Line (https://www.excelbanter.com/excel-programming/278565-dos-command-line.html)

Chris

DOS Command Line
 
My batch file opens the following

"C:\Program Files\Microsoft Office\Office10
\excel.exe" "G:\Customers\Vsource\Clarify.xls"


How do I then run the macro "Sheet1.RefreshData" ?

TonyM

DOS Command Line
 
Put the macro in the 'Workbook Open' sub procedure


-----Original Message-----
My batch file opens the following

"C:\Program Files\Microsoft Office\Office10
\excel.exe" "G:\Customers\Vsource\Clarify.xls"


How do I then run the macro "Sheet1.RefreshData" ?
.


Nikos Yannacopoulos[_2_]

DOS Command Line
 
Open workbook Clarify.xls and open the VB window (right
click on a sheet tab and select "view code").
In the VB Project Explorer window, under Clarify.xls,
expand "Microsoft Excel Objects" and double click on "This
workbook". Click the drop-down list in the top left hand
corner of the editor window (should read (General) by
default) and select "Workbook".
You will see the following appear in the edit area:

Private Sub Workbook_Open()

End Sub

Whatever code you insert between these lines will be
automatically executed everytime you open the workbook.

Nikos Y.

-----Original Message-----
My batch file opens the following

"C:\Program Files\Microsoft Office\Office10
\excel.exe" "G:\Customers\Vsource\Clarify.xls"


How do I then run the macro "Sheet1.RefreshData" ?
.


jaf

DOS Command Line
 
Hi Chris,
From the batch file?
You can't unless you rename the macro Auto_Open() in a general module or
Workbook_Open() in the ThisWorkBook module.
(or call Sheet1.RefreshData from either)


--

John

johnf202 at hotmail dot com


"Chris" wrote in message
...
My batch file opens the following

"C:\Program Files\Microsoft Office\Office10
\excel.exe" "G:\Customers\Vsource\Clarify.xls"


How do I then run the macro "Sheet1.RefreshData" ?




Tom Ogilvy

DOS Command Line
 
Just to expand on some of the useful suggestions already provided:

in G:\Customers\Vsource\Clarify.xls, in the workbook_open, you can call your
macro - you don't have to put the code there.

Private Sub Workbook_Open()
ThisWorkbook.Sheet1.RefreshData
End Sub

Make sure RefreshData has been declared Public.

It might be advisable to move it to a general module rather than have it in
a sheet module. Sheet modules should be used primarily for event related
code.

--
Regards,
Tom Ogilvy


"Chris" wrote in message
...
My batch file opens the following

"C:\Program Files\Microsoft Office\Office10
\excel.exe" "G:\Customers\Vsource\Clarify.xls"


How do I then run the macro "Sheet1.RefreshData" ?




Don Guillett[_4_]

DOS Command Line
 
Put a workbook_open event macro in the ThisWorkbook module.
Right click on the small excel logo square to the left of FILE to insert
this

Private Sub Workbook_Open()
your code
end sub

"Chris" wrote in message
...
My batch file opens the following

"C:\Program Files\Microsoft Office\Office10
\excel.exe" "G:\Customers\Vsource\Clarify.xls"


How do I then run the macro "Sheet1.RefreshData" ?





All times are GMT +1. The time now is 09:11 AM.

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