DOS Command Line

C

Chris

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" ?
 
N

Nikos Yannacopoulos

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.
 
J

jaf

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)
 
T

Tom Ogilvy

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.
 
D

Don Guillett

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top