Running a VB Script

  • Thread starter Thread starter Sofia Katchi
  • Start date Start date
S

Sofia Katchi

Hello.

I am trying to run the following script, which runs a
macro, and it works perfectly except for one detail.

The purpose of the macro is to modify the excel file (it
contains data for labels), save it and call an .exe which
prints the labels.

Every time I run the script, after it is done, a 'File
Available for Use' window pops up telling me that my
excel file is available for editing giving me the option
to open it as 'read/write' or 'cancel'. Even if I hit
cancel, it still tries to open the file. It's doing this
everytime. Is there a way to shut this off? Other than
this, I've run the script multiple times and works just
fine.

-Sofia
 
I thought so too but I checked my code and the script opens the excel
file, runs the macro (which does not try to open it again), and saves
and closes the excel file.

Here's the script:

Dim XL
Dim WB
Set XL = CreateObject("Excel.Application")
Set WB = XL.Workbooks.Open
("C:\2dseismiclabels.xls")
msgbox("about to print labels")
xl.Run "Macro1"
msgbox("finished printing labels")
wb.save
WB.Close
XL.Quit
Set WB = Nothing
Set XL = Nothing
 
Back
Top