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

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.

0
Utf
3/9/2010 3:43:01 AM
access 16762 articles. 3 followers. Follow

8 Replies
2274 Views

Similar Articles

[PageSpeed] 5

"Perry" <Perry@discussions.microsoft.com> wrote in message 
news:270BDFBD-AC48-4487-8917-D90355ECAC0A@microsoft.com...
> 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

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

(please reply to the newsgroup)

0
Dirk
3/9/2010 4:01:29 AM
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. 

0
Utf
3/9/2010 4:37:01 AM
"Perry" <Perry@discussions.microsoft.com> wrote in message 
news:86462F4C-56C5-4B85-8EEC-3AB5167EBF41@microsoft.com...
> 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

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

(please reply to the newsgroup)

0
Dirk
3/9/2010 5:16:10 AM
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
  

"Dirk Goldgar" wrote:

> "Perry" <Perry@discussions.microsoft.com> wrote in message 
> news:270BDFBD-AC48-4487-8917-D90355ECAC0A@microsoft.com...
> > 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
> 
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
> 
> (please reply to the newsgroup)
> 
0
Utf
3/9/2010 5:18:01 AM
"Perry" <Perry@discussions.microsoft.com> wrote in message 
news:CA2DE37A-288F-4797-932B-8378D5E0C94E@microsoft.com...
> 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


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

(please reply to the newsgroup)

0
Dirk
3/9/2010 5:28:53 AM
Hello Dirk,

It works perfectly. Thank you.

"Dirk Goldgar" wrote:

> "Perry" <Perry@discussions.microsoft.com> wrote in message 
> news:CA2DE37A-288F-4797-932B-8378D5E0C94E@microsoft.com...
> > 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
> 
> 
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
> 
> (please reply to the newsgroup)
> 
0
Utf
3/9/2010 2:01:01 PM
"Perry" <Perry@discussions.microsoft.com> wrote in message 
news:270BDFBD-AC48-4487-8917-D90355ECAC0A@microsoft.com...
> 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.
> 

0
De
3/13/2010 5:35:32 PM
kjjkjkj

"Perry" <Perry@discussions.microsoft.com> a écrit dans le message de groupe 
de discussion : 270BDFBD-AC48-4487-8917-D90355ECAC0A@microsoft.com...
> 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.
> 
0
joelgeraldine
3/17/2010 1:50:35 PM
Reply:

Similar Artilces:

Suppress "Do you want to save changes you made to ..." message.
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. "Perry" <Perry@discussions.microsoft.com> wrote in message ne...