Close workbook without saving file

K

Kent.Boucher

Good morning,
I am aware that this issue has been raised
several times, however, i have yet to find a string of code that
actually gets RID of the "would you like to save prompt"!

I am using excel 2003 and i have tried all of the codes below with NO
success:

1) Windows("file_name.xls").Activate
ActiveWorkbook.Close (savechanges = False)

2) currentWorkbook.Close savechanges = False

3) Application.DisplayAlerts = False
ActiveWorkbook.Close

Nothing i have tried from previous articles has helped; any advice
would be greatly appreciated.
 
J

joshuafandango

Hi Kent,

In the 'This Workbook' object:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Saved = True
End Sub

Cheers,
JF.
 
B

Barb Reinhardt

I've used

Application.DisplayAlerts = FALSE

Save code

Application.DisplayAlerts = TRUE

with success. I usually do this though so that I know I'm working on the
correct workbook.

Dim aWB as Workbook

Set aWB = Nothing
on Error resume next
Set aWB = Workbooks("file_name.xls")
on error goto 0

if Not aWB is nothing then ...
Do whatever you'd do with the aWB.
end if
 
J

JP

Try

ActiveWorkbook.Saved = True
ActiveWorkbook.Close

From XL 2003 Help:

You can set this property to True if you want to close a modified
workbook without either saving it or being prompted to save it.


HTH,
JP
 
M

Mike H

maybe this

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Me.Saved = True
End Sub

Mike
 
G

Gary Keramidas

you need a colon before the equals sign

Workbooks(fname).Close savechanges:=False
 
B

Bob Phillips

Do you want to save it or not?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
D

Dave Peterson

You've got to be careful with your syntax:

Windows("file_name.xls").Activate
ActiveWorkbook.Close savechanges:=False

or just:

workbooks("file_name.xls").Close savechanges:=False
 

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