ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a VB Script (https://www.excelbanter.com/excel-programming/271898-running-vbulletin-script.html)

Sofia Katchi

Running a VB Script
 
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

Tom Ogilvy

Running a VB Script
 
Sounds like you might be trying to open the file twice.

Regards,
Tom Ogilvy

"Sofia Katchi" wrote in message
...
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




Sofia K

Running a VB Script
 
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 08:48 AM.

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