Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
If I close a file without saving changes, can I get the autosaved | Excel Discussion (Misc queries) | |||
File/Close automatically saving changes without prompt | Excel Discussion (Misc queries) | |||
Am i the first person to close and excel file, without saving chan | Excel Discussion (Misc queries) | |||
Excel 2003: File->Close without saving changes (save menu does no. | Excel Discussion (Misc queries) | |||
Close file without saving data | Excel Programming |