Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default XL2007 .CodeName bug when copying sheet

My application uses .CodeName property to identify XL sheets.
When copying a sheet within a workbook the new sheets gets the same CodeName
plus Index.
This fails in XL2007 still SP2.

Steps to reproduce bug:

1. Create new workbook
2. Modify .CodeName property of sheet 1 (e.g. test) in VBE
3. Save workbook
4. Close workbook and open it again NOTE: don't start VBE (F11) because
otherwise it works
5. Copy sheet 1 immediately after opening
6. Check .CodeName property of copied sheet
7. BUG: CodeName is not e.g. test1

Does anybody knows a workaround to this problem?

TIA
Reinhard

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default XL2007 .CodeName bug when copying sheet


Followed your instructions and the new sheet appears in the VBE as
Sheet1(Sheet1(2)).


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site' (http://www.excel-it.com/)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=92804

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default XL2007 .CodeName bug when copying sheet

When you add a new sheet with the VBE closed its codename does not exist,
you'll return an empty string (the codemodule is not even created). It's
been like that since Excel-97.

To work around and create the name (ie the sheet's object module) you can
programmatically open/close the VBE. Or, if 'trust access to VB Project' is
allowed, simply refer to the project, eg

Set vbp = activeworkbook.vbproject
or
s = activeworkbook.vbproject.name

Regards,
Peter T


"Reinhard Thomann" wrote in message
...
My application uses .CodeName property to identify XL sheets.
When copying a sheet within a workbook the new sheets gets the same
CodeName
plus Index.
This fails in XL2007 still SP2.

Steps to reproduce bug:

1. Create new workbook
2. Modify .CodeName property of sheet 1 (e.g. test) in VBE
3. Save workbook
4. Close workbook and open it again NOTE: don't start VBE (F11) because
otherwise it works
5. Copy sheet 1 immediately after opening
6. Check .CodeName property of copied sheet
7. BUG: CodeName is not e.g. test1

Does anybody knows a workaround to this problem?

TIA
Reinhard



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default XL2007 .CodeName bug when copying sheet

Hi Peter, royUK

from Excel 97 to 2003 CodeName property workes fine.
Every time a user copies a sheet manually the new one will get CodeName =
CodeNameOfCopiedSheet + Index. Due to this behaviour it's easy for me to
determine
sheets by CodeName property (ActiveSheet.Codename Like Name*).
It fails in Excel 2007 also SP2. Wonder that nobody cares about - is it
possibly a feature? (I can't believe).
I'll give your solution a try.

Thanks
Reinhard

PS. Hope that Microsoft will fix this problem soon!


"Peter T" <peter_t@discussions schrieb im Newsbeitrag
...
When you add a new sheet with the VBE closed its codename does not exist,
you'll return an empty string (the codemodule is not even created). It's
been like that since Excel-97.

To work around and create the name (ie the sheet's object module) you can
programmatically open/close the VBE. Or, if 'trust access to VB Project'
is allowed, simply refer to the project, eg

Set vbp = activeworkbook.vbproject
or
s = activeworkbook.vbproject.name

Regards,
Peter T


"Reinhard Thomann" wrote in message
...
My application uses .CodeName property to identify XL sheets.
When copying a sheet within a workbook the new sheets gets the same
CodeName
plus Index.
This fails in XL2007 still SP2.

Steps to reproduce bug:

1. Create new workbook
2. Modify .CodeName property of sheet 1 (e.g. test) in VBE
3. Save workbook
4. Close workbook and open it again NOTE: don't start VBE (F11) because
otherwise it works
5. Copy sheet 1 immediately after opening
6. Check .CodeName property of copied sheet
7. BUG: CodeName is not e.g. test1

Does anybody knows a workaround to this problem?

TIA
Reinhard




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default XL2007 .CodeName bug when copying sheet

from Excel 97 to 2003 CodeName property workes fine.

Again, a CodeName will not exist until the sheet's object module is created,
which you can force with one of the ways I suggested previously if/as
necessary.

If the VBE is open, or you are copying a sheet that already has its
codemodule, you do not need to do anything.

It's been like this from 97 to 2007-SP1 (I assume similar in SP2 but I don't
have it to test)

Regards,
Peter T

"Reinhard Thomann" wrote in message
...
Hi Peter, royUK

from Excel 97 to 2003 CodeName property workes fine.
Every time a user copies a sheet manually the new one will get CodeName =
CodeNameOfCopiedSheet + Index. Due to this behaviour it's easy for me to
determine
sheets by CodeName property (ActiveSheet.Codename Like Name*).
It fails in Excel 2007 also SP2. Wonder that nobody cares about - is it
possibly a feature? (I can't believe).
I'll give your solution a try.

Thanks
Reinhard

PS. Hope that Microsoft will fix this problem soon!


"Peter T" <peter_t@discussions schrieb im Newsbeitrag
...
When you add a new sheet with the VBE closed its codename does not exist,
you'll return an empty string (the codemodule is not even created). It's
been like that since Excel-97.

To work around and create the name (ie the sheet's object module) you can
programmatically open/close the VBE. Or, if 'trust access to VB Project'
is allowed, simply refer to the project, eg

Set vbp = activeworkbook.vbproject
or
s = activeworkbook.vbproject.name

Regards,
Peter T


"Reinhard Thomann" wrote in message
...
My application uses .CodeName property to identify XL sheets.
When copying a sheet within a workbook the new sheets gets the same
CodeName
plus Index.
This fails in XL2007 still SP2.

Steps to reproduce bug:

1. Create new workbook
2. Modify .CodeName property of sheet 1 (e.g. test) in VBE
3. Save workbook
4. Close workbook and open it again NOTE: don't start VBE (F11) because
otherwise it works
5. Copy sheet 1 immediately after opening
6. Check .CodeName property of copied sheet
7. BUG: CodeName is not e.g. test1

Does anybody knows a workaround to this problem?

TIA
Reinhard








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default XL2007 .CodeName bug when copying sheet

Hi Peter,

thanks for help. The question is, why does Excel 97 to 2003 create the
correct
CodeName and Excel 2007 not. The conditions are the same.
My current (ugly) workaround is to open and close VBE every time a new sheet
is created.
This is only necessary in Excel 2007. The older Excel versions don't need
this workaround.

Your workaround looks smarter. I'll give it a try.
Set vbp = activeworkbook.vbproject

But the best thing would be that Excel 2007 handles CodeName property like
the older versions.

Thanks
Reinhard

"Peter T" <peter_t@discussions schrieb im Newsbeitrag
...
from Excel 97 to 2003 CodeName property workes fine.


Again, a CodeName will not exist until the sheet's object module is
created, which you can force with one of the ways I suggested previously
if/as necessary.

If the VBE is open, or you are copying a sheet that already has its
codemodule, you do not need to do anything.

It's been like this from 97 to 2007-SP1 (I assume similar in SP2 but I
don't have it to test)

Regards,
Peter T

"Reinhard Thomann" wrote in message
...
Hi Peter, royUK

from Excel 97 to 2003 CodeName property workes fine.
Every time a user copies a sheet manually the new one will get CodeName =
CodeNameOfCopiedSheet + Index. Due to this behaviour it's easy for me to
determine
sheets by CodeName property (ActiveSheet.Codename Like Name*).
It fails in Excel 2007 also SP2. Wonder that nobody cares about - is it
possibly a feature? (I can't believe).
I'll give your solution a try.

Thanks
Reinhard

PS. Hope that Microsoft will fix this problem soon!


"Peter T" <peter_t@discussions schrieb im Newsbeitrag
...
When you add a new sheet with the VBE closed its codename does not
exist, you'll return an empty string (the codemodule is not even
created). It's been like that since Excel-97.

To work around and create the name (ie the sheet's object module) you
can programmatically open/close the VBE. Or, if 'trust access to VB
Project' is allowed, simply refer to the project, eg

Set vbp = activeworkbook.vbproject
or
s = activeworkbook.vbproject.name

Regards,
Peter T


"Reinhard Thomann" wrote in message
...
My application uses .CodeName property to identify XL sheets.
When copying a sheet within a workbook the new sheets gets the same
CodeName
plus Index.
This fails in XL2007 still SP2.

Steps to reproduce bug:

1. Create new workbook
2. Modify .CodeName property of sheet 1 (e.g. test) in VBE
3. Save workbook
4. Close workbook and open it again NOTE: don't start VBE (F11) because
otherwise it works
5. Copy sheet 1 immediately after opening
6. Check .CodeName property of copied sheet
7. BUG: CodeName is not e.g. test1

Does anybody knows a workaround to this problem?

TIA
Reinhard






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
XL2007 .CodeName bug when copying sheet Reinhard Thomann[_2_] Excel Programming 3 November 28th 08 09:07 PM
XL2007: Copying worksheets between workbooks Josh Sale[_3_] Excel Programming 0 November 27th 08 12:46 AM
change sheet codename Gary Keramidas Excel Programming 4 March 5th 06 12:54 AM
Selecting a sheet by codename Dr.Schwartz Excel Programming 3 September 3rd 04 02:15 PM
Using sheet codename problems Dustin Carter Excel Programming 1 February 20th 04 10:26 PM


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