Suppress "Do you want to save changes you made to ..." message.

P

Perry

Everytime I try to close an opened excel sheet, I get the message
"Do you want to save the cahnges you made to ........."
How can I suppress the "warning" dialog?

set oOXL = createObject("Excel.Application")
oXL.Visible = False
oXL.workbooks.Open (Filename)
oXL.sheets("Inventory_1").select
....... processing, only reading no modification to sheet ......
oXL.workbooks.Close <<<<< this triggers the message.
Set oXL = Nothing

Thanks.
 
D

Dirk Goldgar

Perry said:
Everytime I try to close an opened excel sheet, I get the message
"Do you want to save the cahnges you made to ........."
How can I suppress the "warning" dialog?

set oOXL = createObject("Excel.Application")
oXL.Visible = False
oXL.workbooks.Open (Filename)
oXL.sheets("Inventory_1").select
...... processing, only reading no modification to sheet ......
oXL.workbooks.Close <<<<< this triggers the message.
Set oXL = Nothing


I don't know, but it may just be that you changed the selection. I suspect
(without testing) that you may have to close the specific workbook, and tell
it not to save changes:

oXL.Workbooks(Filename).Close False
oXL.Workbooks.Close ' may not need this
oXL.Quit
 
P

Perry

Dirk,
Thank you. I still got the message. I've tried many different ways in the
last couple of hours but no success. I am using Office 2003.
 
D

Dirk Goldgar

Perry said:
Dirk,
Thank you. I still got the message. I've tried many different ways in the
last couple of hours but no success. I am using Office 2003.


How about setting the DisplayAlerts property to False?

oXL.DisplayAlerts = False
oXL.Workbooks.Close
oXL.Quit
Set oXL = Nothing
 
P

Perry

Dirk,
I created a short routine. I single cycle the code and found the "Subscript
out of range" error was posted.


set oOXL = createObject("Excel.Application")
oXL.Visible = False
oXL.workbooks.Open ("C:\test\test.xls")
oXL.sheets("test_1").select
oXL.WorkSheets("C:\test\test.xls").Close False <<<<< error detected here.
' oXL.workbooks.Close
oXL.Quit
 
D

Dirk Goldgar

Perry said:
Dirk,
I created a short routine. I single cycle the code and found the
"Subscript
out of range" error was posted.


oXL.WorkSheets("C:\test\test.xls").Close False <<<<< error detected
here.


That's not what I posted, and it couldn't possibly work. It would have to
be:

oXL.Workbooks("C:\test\test.xls").Close False

However, it might be that you have to use just the name of the workbook
file, not its full path:

oXL.Workbooks("test.xls").Close False

Or, it could be that you could avoid explicitly naming the workbook by
writing:

oXL.ActiveWorkbook.Close False
 
P

Perry

Hello Dirk,

It works perfectly. Thank you.

Dirk Goldgar said:
That's not what I posted, and it couldn't possibly work. It would have to
be:

oXL.Workbooks("C:\test\test.xls").Close False

However, it might be that you have to use just the name of the workbook
file, not its full path:

oXL.Workbooks("test.xls").Close False

Or, it could be that you could avoid explicitly naming the workbook by
writing:

oXL.ActiveWorkbook.Close False


--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 
D

De Jager

Perry said:
Everytime I try to close an opened excel sheet, I get the message
"Do you want to save the cahnges you made to ........."
How can I suppress the "warning" dialog?

set oOXL = createObject("Excel.Application")
oXL.Visible = False
oXL.workbooks.Open (Filename)
oXL.sheets("Inventory_1").select
...... processing, only reading no modification to sheet ......
oXL.workbooks.Close <<<<< this triggers the message.
Set oXL = Nothing

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top