View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron McCormick Ron McCormick is offline
external usenet poster
 
Posts: 8
Default Problem with Activeworkbook.Close SaveChanges:=False

Tom,

Thanks for your reponse.

Your guess seems like it should be the source of the problem, but on
"looking" at what happens when I run the code it appears that the right
workbook is active.

Early in the process the file from which the data is copied is set as
"TownT" with the following code.

Set TownT = Workbooks.Open(FileName:=ThisWorkbook.Path & "\" & CentreName)
'opens file from centre name list

The code leading up to where the procedure crashes is:

TownT.Activate
Application.EnableEvents = True
ActiveWorkbook.Close SaveChanges:=False

And whenever the code runs the TownT file does appear to be active. This
appears to be confrimed in that when you end the process the relevant file
does close with out saving. The error message that I'm getting is "Error '9'
: Subscript out of range".

Any further help woiuld be appreciated.

Thanks again,
Ron

"Tom Ogilvy" wrote:

My guess would be that the file that seems to fail is not the activeworkbook
when the code is run.

Other than that, I have never seen a problem with that command.

--
Regards,
Tom Ogilvy


"Ron McCormick" wrote:

I have a model that opens files, copies data from the file opened, and is
supposed then to close the file with: Activeworkbook.Close
SaveChanges:=False. It has worked satisfactorily for years but seems to have
stopped working recently, following an update of the files from which the
data is extracted. Any ideas why this might be happening?

TIA

Ron