Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Problem with Activeworkbook.Close SaveChanges:=False

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Problem with Activeworkbook.Close SaveChanges:=False

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Problem with Activeworkbook.Close SaveChanges:=False

Does this work as expected ?
TownT.Close SaveChanges:=False

Any extra code in the _BeforeClose events ?

NickHK

"Ron McCormick" wrote in message
...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Problem with Activeworkbook.Close SaveChanges:=False

Thanks Nick,

You're a star. I'd forgotten about the workbook BeforeClose event, as one
of the sheet names had changed in the file from which the data is taken, but
the Workbook_BeforeClose event had not been changed to reflect that.

Credit too to Tom who rightly pointed out that the problem was (likely) in
the file to be closed.

Many thanks,
Ron

"NickHK" wrote:

Does this work as expected ?
TownT.Close SaveChanges:=False

Any extra code in the _BeforeClose events ?

NickHK

"Ron McCormick" wrote in message
...
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




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
VBA - Do Loop or SaveChanges = false Dan Excel Discussion (Misc queries) 1 January 23rd 09 05:54 PM
ActiveWorkbook.Close (False) stefan via OfficeKB.com Excel Programming 3 July 12th 05 12:42 AM
workbook.close savechanges:=True problem Dave the Wave Excel Programming 3 January 19th 05 08:44 PM
close(savechanges,filename,routeworkbook) Zygoid[_11_] Excel Programming 2 January 31st 04 06:06 PM
ActiveWorkbook.Close Matthew[_9_] Excel Programming 4 November 13th 03 02:48 AM


All times are GMT +1. The time now is 09:04 PM.

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"