Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Subscript out of Range - CodeName

I'm getting a 'Subscript out of range' error on a line of code as follows

ThisWorkbook.VBProject.VBComponents(ActiveSheet.Co deName).Properties("_CodeName").Value = "Output" & Now * 10000000000#

The odd thing is the fact that this only occurs the first time the code is
run when the workbbok is opened and, when I select debug the error, all I
simply do is press run (play button) and the code conitnues on perfectly with
the new codename for the active sheet. I've also changed the 'NOW *
10000000000#' to '12' and I got the same error (I couldn't test it for the
second use as a codename conflict would occur).

Any thoughts as to why this happens and how to fix it would be greatly
appreciated. I already have tried 'On Error Resume Next' but that didn't
work. It still halted my procedure.


--
Cheers!

Richard Reye

"Never argue with an idiot. They'll bring you down to their level then beat
you with experience" - someone
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Subscript out of Range - CodeName

Not sure if this helps - but i tried your code Excel 2002 SP-2 VB6.3 and
it works fine. I could not get it to throw an error either in open workbook
event or a module, repeated use did not either !

--
Cheers
Nigel



"Richard Reye" wrote in message
...
I'm getting a 'Subscript out of range' error on a line of code as follows


ThisWorkbook.VBProject.VBComponents(ActiveSheet.Co deName).Properties("_CodeN
ame").Value = "Output" & Now * 10000000000#

The odd thing is the fact that this only occurs the first time the code is
run when the workbbok is opened and, when I select debug the error, all I
simply do is press run (play button) and the code conitnues on perfectly

with
the new codename for the active sheet. I've also changed the 'NOW *
10000000000#' to '12' and I got the same error (I couldn't test it for the
second use as a codename conflict would occur).

Any thoughts as to why this happens and how to fix it would be greatly
appreciated. I already have tried 'On Error Resume Next' but that didn't
work. It still halted my procedure.


--
Cheers!

Richard Reye

"Never argue with an idiot. They'll bring you down to their level then

beat
you with experience" - someone



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Subscript out of Range - CodeName

Your code worked for me just fine. You might try shortening it to

ThisWorkbook.VBProject.VBComponents(ActiveSheet.Co deName).Name =
_
"Output" & Now * 10000000000#

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Richard Reye" wrote in message
...
I'm getting a 'Subscript out of range' error on a line of code
as follows

ThisWorkbook.VBProject.VBComponents(ActiveSheet.Co deName).Properties("_CodeName").Value
= "Output" & Now * 10000000000#

The odd thing is the fact that this only occurs the first time
the code is
run when the workbbok is opened and, when I select debug the
error, all I
simply do is press run (play button) and the code conitnues on
perfectly with
the new codename for the active sheet. I've also changed the
'NOW *
10000000000#' to '12' and I got the same error (I couldn't test
it for the
second use as a codename conflict would occur).

Any thoughts as to why this happens and how to fix it would be
greatly
appreciated. I already have tried 'On Error Resume Next' but
that didn't
work. It still halted my procedure.


--
Cheers!

Richard Reye

"Never argue with an idiot. They'll bring you down to their
level then beat
you with experience" - someone



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Subscript out of Range - CodeName

Are you doing this in the Workbook.Open event. I would try qualifying
Activesheet

ThisWorkbook.VBProject.VBComponents(ThisWorkbook.A ctiveSheet.CodeName _
).Properties("_CodeName").Value = "Output" & Now * 10000000000#

--
Regards,
Tom Ogilvy


"Richard Reye" wrote in message
...
I'm getting a 'Subscript out of range' error on a line of code as follows


ThisWorkbook.VBProject.VBComponents(ActiveSheet.Co deName).Properties("_CodeN
ame").Value = "Output" & Now * 10000000000#

The odd thing is the fact that this only occurs the first time the code is
run when the workbbok is opened and, when I select debug the error, all I
simply do is press run (play button) and the code conitnues on perfectly

with
the new codename for the active sheet. I've also changed the 'NOW *
10000000000#' to '12' and I got the same error (I couldn't test it for the
second use as a codename conflict would occur).

Any thoughts as to why this happens and how to fix it would be greatly
appreciated. I already have tried 'On Error Resume Next' but that didn't
work. It still halted my procedure.


--
Cheers!

Richard Reye

"Never argue with an idiot. They'll bring you down to their level then

beat
you with experience" - someone



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
what does 'Subscript Out of range' mean?? Gary Excel Worksheet Functions 2 March 22nd 07 01:33 AM
9: Subscript out of range jenz21985 Excel Discussion (Misc queries) 6 May 5th 06 03:36 PM
Subscript is out of Range teresa Excel Programming 2 December 19th 04 05:00 PM
Subscript out of range Stacy Haskins[_2_] Excel Programming 4 April 10th 04 05:41 AM
Subscript Out of Range John Wilson Excel Programming 2 September 7th 03 04:07 AM


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