Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime Error - Subscript out of range despite On Error statement | Excel Programming | |||
Subscript out of range error - save copy error | Excel Programming | |||
Subscript out of range error - save copy error | Excel Programming | |||
Subscript out of range error | Excel Programming | |||
Type Mismatch error & subscript out of range error | Excel Programming |