LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Subscript out of range error

Adding the xls extension did the trick. If an end user happens to change
the file name will the code then fail again?


As a general rule, you should always use the ".xls" file extension
when using the workbook name with the Workbooks collection. It will
always work. Omitting the ".xls" extension will work if the user has
the "Hide extensions of known file types" option in effect. This is a
Windows option, not an Excel option.

See http://www.cpearson.com/excel/FileExtensions.aspx for more
information.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Fri, 15 May 2009 10:45:01 -0700, Ken Warthen
wrote:


Jacob,

Adding the xls extension did the trick. If an end user happens to change
the file name will the code then fail again?

Ken
"Jacob Skaria" wrote:

What is the error?? Is should be "Drink Plan.xls"

Workbooks("Drink Plan.xls").Activate
Workbooks("Drink Plan.xls").Worksheets("Price Groups").Visible = True


If this post helps click Yes
---------------
Jacob Skaria


"Ken Warthen" wrote:


Jacob,

Thanks for the help. I changed the Workbooks reference to the following.

Workbooks("Drink Plan").Worksheets("Price Groups").Visible = True

The code continues to fail.

Ken

"Jacob Skaria" wrote:

Try the below. Specify the workbook..in between the quotes


Workbooks("<workbookname").Sheets("Price Plan").Visible = True

--
If this post helps click Yes
---------------
Jacob Skaria


"Ken Warthen" wrote:

I have an Excel 2003 format spreadsheet with quite a bit of VBA code to
validate user entries, create reports, and as code behind several userforms.
I've got everything working fine, except it the user has a second spreadsheet
open in which case my login userform fails with an error 9, subscript out of
range error message on the following line.

Workbooks(1).Worksheet("Price Plan").Visible=True

Any idea on why my code is failing, and how it can be fixed?

TIA,

Ken

 
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
Subscript out of range Error ch Excel Programming 2 October 15th 07 02:59 PM
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
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 03:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"