|
-
Jun 30th, 2002, 09:40 PM
#1
Thread Starter
PowerPoster
closing an excel file opened in VB
I open an excel file, stuff in some data, close it and kill it.
everything works fine but the close process brings up a system messge asking if I"d like to save the changes. I'm sure that I've seen a way to make the close process tell the system to save without asking, but now I can't find that technique anywhere in
the on-line help, so if anyone knows it, I'd appreciate the syntax.
my close is just:
xlApp.Workbooks.Close
and I think it can be something like
xlApp.Workbooks.Close vbSaveWithoutAsking
(you get the idea)
thanks
-
Jun 30th, 2002, 10:35 PM
#2
Addicted Member
I dunno but couldnt you just tell it to save and then to close? Post the code and ill take a look at it.
-
Jun 30th, 2002, 10:50 PM
#3
Thread Starter
PowerPoster
couldnt you just tell it to save and then to close?
I not only could, I do, of necessity. However, the point is that several others in the office use the application and they aren't computer literate and it makes them nervous that the system asks them whether or not to save something. I'd like to automate it.
The relevant code is:
VB Code:
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open(cfg_path & "\" & "template.xls", , True)
Set xlDataSheet = xlBook.Worksheets("Data")
Set xlSumSheet = xlBook.Worksheets("Sums")
'
' push lots of stuff into the spreadsheet
'
xlApp.Workbooks.Close
xlApp.Quit
Set xlApp = Nothing
Thanks for your time.
-
Jul 1st, 2002, 04:43 AM
#4
Two little bits of code for you:
close without saving:
ActiveWorkbook.Close savechanges:=False
save to specific file:
ActiveWorkbook.Saveas filename
(see the help for all the options: file type etc)
-
Jul 1st, 2002, 08:04 AM
#5
Thread Starter
PowerPoster
thanks --- this got me to what I need
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|