Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Closing Application

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,87
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Closing Application
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Closing Application - 6/2/2001 12:30:23 AM   
  ekiko

 

Posts: 14
Score: 0
Joined: 5/23/2001
From: New Zealand
Status: offline
What is the 'logical' reverse of the following open?


Set objExcel = GetObject("",
"excel.application")
objExcel.Workbooks.open strFullPath


In other words, how do you close the current document AND the
workbook. One would think it would be:


objExcel.ActiveWorkBook.Close
objExcel.Close


but the first line does what is expected, the second line is invalid.
Just what am I missing here?
Also, how can you make it close the workbook and NOT prompt
for rewriting permission after modifications are made?

Thanks
 
 
Post #: 1
 
 Re: Closing Application - 6/2/2001 12:33:03 AM   
  itan

 

Posts: 10
Score: 0
Joined: 5/31/2001
From: USA
Status: offline
Hi

You going to have to change the statement to the following

objExcel.Quit
'It's probably best to follow that up
with
Set objExcel = Nothing

As for your second question

If unsaved workbooks are open when you use .Quit,
Excel displays a dialog box asking whether you want to save the
changes.
This can be prevented by saving all workbooks before using
the Quit method -

For Each objWrkBook in
objExcel.Workbooks
objWrkBook.Save
Next

The other way to do this is to set the DisplayAlerts
property to False. When this property is False, Excel doesn't
display the dialog box when you quit with unsaved
workbooks, but it quits without saving them.

objExcel.DisplayAlerts = False

NB* You must set this back to True when you done as it's
not done automatically

Another way to do this is to set the Saved property for a
workbook to true without saving the workbook to the disk, this
sort of "fools" excel into thinking the workbook
is saved. (When you quit excel, it checks this flag to
determine if there are any workbooks to be saved)

objWorkBook.Saved = True
objWorkBook.Close 'This will discard
all unsaved changes

THe .Path property of the Workbook object contains an empty
string ("") if a workbook is not saved.
Microsoft Excel does not however check this property when you
close a workbook

Msgbox objWorkBook.Path

(in reply to ekiko)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Closing Application Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts