Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Close file without saving


Hi all,

I'm having a problem with closing a file without the message 'Do yo
want to save the changes, Yes/No/Cancel'.
What's my problem? Well, I had a file containing a macro that had t
open a couple of files, one at a time, look for a value in a cell, an
depending on that value, close the file immediately or first perfor
some actions, copy some cells to the mainfile and close the file
Without changes. And then the next file and so on. I had the comman
'Application.DisplayAlerts = False' in the macro and it always worke
without any problems.
I haven't used this macro in a year, but now I want to use this macr
for another Network Drive (another location of the sourcefiles). Thes
files open Read-Only.
However, when I run the macro, I get the message 'Do you want to sav
changes?' when the macro closes a file where some cells are copied an
pasted.

Now, it isn't really a big problem, because I guess it could work i
the macro copies the worksheet first to the mainfile and closes th
sourcefile. Probably then the macro will consider the sourcefile a
not-changed. But before I'm changing the macro, I would like to know i
there's anyone who has experienced the same.

Here's what I've tried so far:
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
Workbooks(sourcefilename).Close SaveChanges:=False

But nevertheless, I still get the 'Change? Yes/No/Cancel'-messages. An
then, it doesn't really matter what option I choose (Yes or No), becaus
Excel doesn't close the file anyway. Since the macro has to handle som
tens/hundreds of files, that's really annoying. Furthermore, the macr
crashes because the activeworkbook is the file that should be closed.
could easily fix that too, I know.

What's really the problem is that I can't stand it that Excel keep
showing the message, even though I put the displayalerts off, an
refuses to close the file. Is it because the files open Read-Only, o
is it that I have another Excelversion? Has anyone of you experience
the same and does anyone know what to do about it?

Regards,

Anne

--
Roadi
-----------------------------------------------------------------------
Roadie's Profile: http://www.excelforum.com/member.php...nfo&userid=593
View this thread: http://www.excelforum.com/showthread.php?threadid=27153

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Close file without saving

You say excel then doesn't close the file.

From your description, it sounds like you are getting the prompt for a file
different from the one you intend to close. You need to look more closely
at how you are referencing the file.

I have never seen a prompt from

workbooks(sourcename).Close SaveChanges:=False
There wouldn't be much point in having the SaveChanges Argument since it is
provided to answer that question.

--
Regards,
Tom Ogilvy



"Roadie" wrote in message
...

Hi all,

I'm having a problem with closing a file without the message 'Do you
want to save the changes, Yes/No/Cancel'.
What's my problem? Well, I had a file containing a macro that had to
open a couple of files, one at a time, look for a value in a cell, and
depending on that value, close the file immediately or first perform
some actions, copy some cells to the mainfile and close the file.
Without changes. And then the next file and so on. I had the command
'Application.DisplayAlerts = False' in the macro and it always worked
without any problems.
I haven't used this macro in a year, but now I want to use this macro
for another Network Drive (another location of the sourcefiles). These
files open Read-Only.
However, when I run the macro, I get the message 'Do you want to save
changes?' when the macro closes a file where some cells are copied and
pasted.

Now, it isn't really a big problem, because I guess it could work if
the macro copies the worksheet first to the mainfile and closes the
sourcefile. Probably then the macro will consider the sourcefile as
not-changed. But before I'm changing the macro, I would like to know if
there's anyone who has experienced the same.

Here's what I've tried so far:
Application.DisplayAlerts = False
ThisWorkbook.Saved = True
Workbooks(sourcefilename).Close SaveChanges:=False

But nevertheless, I still get the 'Change? Yes/No/Cancel'-messages. And
then, it doesn't really matter what option I choose (Yes or No), because
Excel doesn't close the file anyway. Since the macro has to handle some
tens/hundreds of files, that's really annoying. Furthermore, the macro
crashes because the activeworkbook is the file that should be closed. I
could easily fix that too, I know.

What's really the problem is that I can't stand it that Excel keeps
showing the message, even though I put the displayalerts off, and
refuses to close the file. Is it because the files open Read-Only, or
is it that I have another Excelversion? Has anyone of you experienced
the same and does anyone know what to do about it?

Regards,

Annet


--
Roadie
------------------------------------------------------------------------
Roadie's Profile:

http://www.excelforum.com/member.php...fo&userid=5936
View this thread: http://www.excelforum.com/showthread...hreadid=271530



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If I close a file without saving changes, can I get the autosaved jimp Excel Discussion (Misc queries) 0 July 31st 09 01:20 AM
File/Close automatically saving changes without prompt Joe@SAA Excel Discussion (Misc queries) 0 June 23rd 08 10:31 PM
Am i the first person to close and excel file, without saving chan Cjbrad Excel Discussion (Misc queries) 3 March 2nd 06 07:58 PM
Excel 2003: File->Close without saving changes (save menu does no. Wai-Yee Excel Discussion (Misc queries) 5 July 25th 05 11:49 PM
Close file without saving data ExcelMonkey[_96_] Excel Programming 2 March 2nd 04 11:34 PM


All times are GMT +1. The time now is 11:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"