Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CH CH is offline
external usenet poster
 
Posts: 49
Default Subscript out of range Error

I have a VBA that is :

set WH = workbook("file1"). file1 is an open excel workbook.

It works fine mostly but on 1 of my colleagues' PC, it gives "subscription
out of range".

We were told to change the line to :
set WH = workbook("file1.xls") with the xls extension and it now works fine.

How can we get VBA to accept both file1 and file1.xls as valid input?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Subscript out of range Error

Check your other post.

ch wrote:

I have a VBA that is :

set WH = workbook("file1"). file1 is an open excel workbook.

It works fine mostly but on 1 of my colleagues' PC, it gives "subscription
out of range".

We were told to change the line to :
set WH = workbook("file1.xls") with the xls extension and it now works fine.

How can we get VBA to accept both file1 and file1.xls as valid input?

Thanks.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Subscript out of range Error

When you are defining the object variable with the Set method, you must use
the three digit (four with xl2007) file extension code preceded by a period
[.] . This is because Excel files can have several different file extension
codes for the same basic name. You have charts, templates, macro sheets,
etc. that can all have the same basic name as the .xls file.

"ch" wrote:

I have a VBA that is :

set WH = workbook("file1"). file1 is an open excel workbook.

It works fine mostly but on 1 of my colleagues' PC, it gives "subscription
out of range".

We were told to change the line to :
set WH = workbook("file1.xls") with the xls extension and it now works fine.

How can we get VBA to accept both file1 and file1.xls as valid input?

Thanks.

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
Runtime Error - Subscript out of range despite On Error statement DoctorG Excel Programming 3 July 28th 06 03:56 PM
Subscript out of range error - save copy error bg18461[_16_] Excel Programming 2 June 13th 06 04:53 PM
Subscript out of range error - save copy error bg18461[_15_] Excel Programming 1 June 13th 06 04:36 PM
Subscript out of range error kev_06[_9_] Excel Programming 2 June 6th 06 11:18 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM


All times are GMT +1. The time now is 08:24 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"