Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Identifying an open workbook / sheet

My process fails - error 9: subscript out of range at this statement:-
With Workbooks(Cranafile).Worksheets(SheetName)
on one PC! On all other PC's the macro works fine. The workbook defined by
cranafile is definately open and definately has a sheet called sheetname. On
my PC I can have the string defined in any case (upper or lower) and all is
OK with or without the .xls extension. On this maveric PC I've had to add
code to ensure the book and sheet names are exactly as held in
workbooks(<bookid).name to make the with or any subsequent code find the
book and sheet. Why is this ? The maveric PC in on windows NT (I think) and
has recently had Excel re-installed. Is there a known bug in Excel here or in
there some parameter I need to set ? This was a real pain to find and code
round so any advice would be appreciated. Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Identifying an open workbook / sheet

I think it's more of a windows/code problem than excel.

There's a windows setting that hides/displays file extensions. If you don't
specify the extension, then you code could fail (depending on this setting).

If you include the extension, then it'll work all the time--no matter what the
setting.

so instead of:
cranafile = "book1"
use
cranafile = "book1.xls"

(well, that's my guess!)




John Pritchard wrote:

My process fails - error 9: subscript out of range at this statement:-
With Workbooks(Cranafile).Worksheets(SheetName)
on one PC! On all other PC's the macro works fine. The workbook defined by
cranafile is definately open and definately has a sheet called sheetname. On
my PC I can have the string defined in any case (upper or lower) and all is
OK with or without the .xls extension. On this maveric PC I've had to add
code to ensure the book and sheet names are exactly as held in
workbooks(<bookid).name to make the with or any subsequent code find the
book and sheet. Why is this ? The maveric PC in on windows NT (I think) and
has recently had Excel re-installed. Is there a known bug in Excel here or in
there some parameter I need to set ? This was a real pain to find and code
round so any advice would be appreciated. Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Identifying an open workbook / sheet

Thanks Dave - sounds like this is what was happening. I'll have a hunt round
for the windows setting to see if it makes the difference.

"Dave Peterson" wrote:

I think it's more of a windows/code problem than excel.

There's a windows setting that hides/displays file extensions. If you don't
specify the extension, then you code could fail (depending on this setting).

If you include the extension, then it'll work all the time--no matter what the
setting.

so instead of:
cranafile = "book1"
use
cranafile = "book1.xls"

(well, that's my guess!)




John Pritchard wrote:

My process fails - error 9: subscript out of range at this statement:-
With Workbooks(Cranafile).Worksheets(SheetName)
on one PC! On all other PC's the macro works fine. The workbook defined by
cranafile is definately open and definately has a sheet called sheetname. On
my PC I can have the string defined in any case (upper or lower) and all is
OK with or without the .xls extension. On this maveric PC I've had to add
code to ensure the book and sheet names are exactly as held in
workbooks(<bookid).name to make the with or any subsequent code find the
book and sheet. Why is this ? The maveric PC in on windows NT (I think) and
has recently had Excel re-installed. Is there a known bug in Excel here or in
there some parameter I need to set ? This was a real pain to find and code
round so any advice would be appreciated. Thanks


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Identifying an open workbook / sheet

In win98, I'd do this:

Start windows explorer
View Tab|Uncheck the "hide file extensions for known file types"




John Pritchard wrote:

Thanks Dave - sounds like this is what was happening. I'll have a hunt round
for the windows setting to see if it makes the difference.

"Dave Peterson" wrote:

I think it's more of a windows/code problem than excel.

There's a windows setting that hides/displays file extensions. If you don't
specify the extension, then you code could fail (depending on this setting).

If you include the extension, then it'll work all the time--no matter what the
setting.

so instead of:
cranafile = "book1"
use
cranafile = "book1.xls"

(well, that's my guess!)




John Pritchard wrote:

My process fails - error 9: subscript out of range at this statement:-
With Workbooks(Cranafile).Worksheets(SheetName)
on one PC! On all other PC's the macro works fine. The workbook defined by
cranafile is definately open and definately has a sheet called sheetname. On
my PC I can have the string defined in any case (upper or lower) and all is
OK with or without the .xls extension. On this maveric PC I've had to add
code to ensure the book and sheet names are exactly as held in
workbooks(<bookid).name to make the with or any subsequent code find the
book and sheet. Why is this ? The maveric PC in on windows NT (I think) and
has recently had Excel re-installed. Is there a known bug in Excel here or in
there some parameter I need to set ? This was a real pain to find and code
round so any advice would be appreciated. Thanks


--

Dave Peterson


--

Dave Peterson
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
open to a certain sheet tab in a different workbook akay71 New Users to Excel 1 June 5th 08 05:01 PM
Search open sheets in workbook and insert into open sheet punx77 Excel Discussion (Misc queries) 0 March 6th 06 05:07 PM
Open workbook on same sheet? mevetts Excel Discussion (Misc queries) 2 December 21st 05 11:15 AM
Open workbook at a particular sheet George Gee New Users to Excel 2 October 15th 05 12:54 PM
open sheet on workbook open Stu[_31_] Excel Programming 4 October 20th 03 01:38 AM


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