PC Review


Reply
Thread Tools Rate Thread

out of range problem in workbook closing

 
 
hlam
Guest
Posts: n/a
 
      18th Dec 2004
I got an Out of Range error closing a workbook using VBA on one machine but
not the other. Can any one help?

fName = Left(ThisWorkbook.Path, pos) & "SYS01 Report.xls"
Workbooks.Open Filename:=fName
Sheets(1).Select
Sheets(1).Copy Before:=Workbooks("SYS01 Program.xls").Sheets(1)
Workbooks("SYS01 Report").Saved = True
Workbooks("SYS01 Report").Close ... this is the code gets the error
ThisWorkbook.Sheets(1).Name = "CTL"


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      18th Dec 2004
Try adding .xls to each of these lines:

Workbooks("SYS01 Report").Saved = True
Workbooks("SYS01 Report").Close

Workbooks("SYS01 Report.xls").Saved = True
Workbooks("SYS01 Report.xls").Close

There's a windows setting that allows users to hide/show extensions. To be
careful, you can always include the extension and it'll work no matter the what
the user chose for that setting.


hlam wrote:
>
> I got an Out of Range error closing a workbook using VBA on one machine but
> not the other. Can any one help?
>
> fName = Left(ThisWorkbook.Path, pos) & "SYS01 Report.xls"
> Workbooks.Open Filename:=fName
> Sheets(1).Select
> Sheets(1).Copy Before:=Workbooks("SYS01 Program.xls").Sheets(1)
> Workbooks("SYS01 Report").Saved = True
> Workbooks("SYS01 Report").Close ... this is the code gets the error
> ThisWorkbook.Sheets(1).Name = "CTL"


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Workbook.Range Problem kylekelsch@hotmail.com Microsoft Excel Programming 4 12th Apr 2007 04:01 PM
Subscript Out of Range when closing a workbook Andibevan Microsoft Excel Programming 3 9th Sep 2006 08:37 PM
Problem with closing workbook in macro =?Utf-8?B?c2xt?= Microsoft Excel Programming 1 11th Jun 2005 02:23 AM
Problem copying a range to a different workbook BobE@sympatico.ca Microsoft Excel Programming 3 8th Dec 2004 02:43 AM
Problem closing a workbook using a macro Steve Microsoft Excel Programming 3 21st Sep 2004 02:03 PM


Features
 

Advertising
 

Newsgroups
 


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