Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatic exit? 1

Status
Not open for further replies.

dswitzer

Technical User
Aug 2, 2002
298
US
I am using a .bat file to call a workbook -- it will run a macro, and then close.

The .bat file works fine and is simply:
Code:
call C:\test.xls

In the spreadsheet, I have

Code:
Private Sub Workbook_Open()
    Call macro1
    Call workbook_close
End Sub

Private Sub workbook_close()
     ActiveWorkbook.Close savechanges:=True
End Sub

Everything runs fine. The only issue I have is that after the workbook closes - the excel application still exists -- how can I close this (either from excel or the batch file)...

Thanks.

Dave


 
Code:
Application.Quit

Hope this helps

HarleyQuinn
---------------------------------
The most overlooked advantage to owning a computer is that if they foul up there's no law against wacking them around a little. - Joe Martin

Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 




Code:
Private Sub workbook_close()
     ActiveWorkbook.Close savechanges:=True
     application.quit
End Sub
[/code


Skip,
[sub]
[glasses]Did you hear what happened when the OO programmer lost his library?...
[b]He's now living in OBJECT poverty![/b][tongue][/sub]
 
You know - I tried that yesterday -- and I just tried it again and it did not close the app window...very odd...no errors, the code was "recognized" when I added it -- as it capitalized the code to Application.Quit It just didn't work. Is there a setting somewhere that I am missing?

The workbook closes fine but the Excel app window still is left...

Thanks.

Dave
 
For some reason do you have 2 instances of excel open

ck1999
 
Good question - but no. I ran through the process again -- watching the task manager -- never more than one Excel window open...
 
If the code is in the activeworkbook, and the activeworkbook is closed, it cannot continue running the code.

Use Application.Quit without first closing the WB.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
John. Nail. Head.
Code:
Activeworkbook.save
application.quit

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
I like what xlbo wrote. Is there a way to add a 10 min timer? Run the macro then 10 min later the app saves the work and turns off .
Thanks
Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top