Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
After loading a file when I issue the command
Windows(TheWb).Activate where TheWB is the name of the file (with or without the path, doesn't matter), I am getting an error: "Runtime Error 9, Subscript out of range". What do I need to change? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use the .xls extension in the file name. E.g.,
Windows("Book1.xls").Activate instead of Windows("Book1").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "Mike H." wrote in message ... After loading a file when I issue the command Windows(TheWb).Activate where TheWB is the name of the file (with or without the path, doesn't matter), I am getting an error: "Runtime Error 9, Subscript out of range". What do I need to change? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I have the filename "xxx.xls" in place of the variable thewb or if I have
the variable thewb which = xxx.xls, I still get the same error, #9, Subscript error. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you have multiple windows of the same workbook open? If you do, you'll
see something like FileName.xls:1 or FileName.xls:2 in the title bar of Excel. If this is the case, you must include the window number in the Windows reference. E.g., Windows("Book1.xls:1").Close Or, you can close all but one window with code like With Workbooks("Book1.xls").Windows Do Until .Count = 1 .Item(1).Close Loop End With -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "Mike H." wrote in message ... If I have the filename "xxx.xls" in place of the variable thewb or if I have the variable thewb which = xxx.xls, I still get the same error, #9, Subscript error. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
What about the extension (with/without) Also you could do something like: Dim Wbk as workbook Set Wbk= Workbooks.Open ( .... your file ....) ''' returns the opened book into a variable Wbk.Windows(1).Activate -- Regards, Sébastien <http://www.ondemandanalysis.com "Mike H." wrote: After loading a file when I issue the command Windows(TheWb).Activate where TheWB is the name of the file (with or without the path, doesn't matter), I am getting an error: "Runtime Error 9, Subscript out of range". What do I need to change? |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
something like this:
Sub test2() Dim fPath As String Dim fname As String Dim wb2 As Workbook fPath = "D:\My Documents\Excel\" fname = fPath & "Book1.xls" Set wb2 = Workbooks.Open(Filename:=fname) Windows(wb2.Name).Activate End Sub -- Gary "Mike H." wrote in message ... After loading a file when I issue the command Windows(TheWb).Activate where TheWB is the name of the file (with or without the path, doesn't matter), I am getting an error: "Runtime Error 9, Subscript out of range". What do I need to change? |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't know what is going on, but I am still getting the same error 9
subscript out of range when I use even this code. "Gary Keramidas" wrote: something like this: Sub test2() Dim fPath As String Dim fname As String Dim wb2 As Workbook fPath = "D:\My Documents\Excel\" fname = fPath & "Book1.xls" Set wb2 = Workbooks.Open(Filename:=fname) Windows(wb2.Name).Activate End Sub -- Gary "Mike H." wrote in message ... After loading a file when I issue the command Windows(TheWb).Activate where TheWB is the name of the file (with or without the path, doesn't matter), I am getting an error: "Runtime Error 9, Subscript out of range". What do I need to change? |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about just using:
wb2.activate Mike H. wrote: I don't know what is going on, but I am still getting the same error 9 subscript out of range when I use even this code. "Gary Keramidas" wrote: something like this: Sub test2() Dim fPath As String Dim fname As String Dim wb2 As Workbook fPath = "D:\My Documents\Excel\" fname = fPath & "Book1.xls" Set wb2 = Workbooks.Open(Filename:=fname) Windows(wb2.Name).Activate End Sub -- Gary "Mike H." wrote in message ... After loading a file when I issue the command Windows(TheWb).Activate where TheWB is the name of the file (with or without the path, doesn't matter), I am getting an error: "Runtime Error 9, Subscript out of range". What do I need to change? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Getting error with load/unload of UserForms?? | Excel Programming | |||
Validation Load Error | Excel Discussion (Misc queries) | |||
cannot load excel file - "too many different cell formats" error s | Excel Discussion (Misc queries) | |||
Is it possible to load an .xls file | Excel Programming | |||
new error when try to load userform | Excel Programming |