Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Code Module in Sheets Collection

I am looping through all sheets in a workbook and come across a sheet
that is named the same a one of the code modules and is
xlsheetveryhidden. I changed the code module name with VBE and re-ran
the code. The name changed to the new name. How could this be
possible?

I believe this is a very old workbook. Could this have anything to do
with macrosheets? The sheet does not have a codename.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Code Module in Sheets Collection

"CG" wrote in message
...
I am looping through all sheets in a workbook and come across a sheet
that is named the same a one of the code modules and is
xlsheetveryhidden. I changed the code module name with VBE and re-ran
the code. The name changed to the new name. How could this be
possible?

I believe this is a very old workbook. Could this have anything to do
with macrosheets? The sheet does not have a codename.


This is typical of workbooks with VBA code modules that were created in
Excel 5/95. To convert the module into a current version code module, the
easiest thing to do is to first make sure the module has a valid code module
name (no spaces or non alphanumeric characters). Then export the module,
remove it from the project and import it back into the project. A new
version module will be created upon import and the module name should then
disappear from the Sheets collection.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Code Module in Sheets Collection

On Jun 2, 1:11 pm, "Rob Bovey" wrote:
"CG" wrote in message

...

I am looping through allsheetsin a workbook and come across a sheet
that is named the same a one of thecodemodules and is
xlsheetveryhidden. I changed thecodemodulename with VBE and re-ran
thecode. The name changed to the new name. How could this be
possible?


I believe this is a very old workbook. Could this have anything to do
with macrosheets? The sheet does not have a codename.


This is typical of workbooks with VBAcodemodules that were created in
Excel 5/95. To convert themoduleinto a current versioncodemodule, the
easiest thing to do is to first make sure themodulehas a validcodemodule
name (no spaces or non alphanumeric characters). Then export themodule,
remove it from the project and import it back into the project. A new
versionmodulewill be created upon import and themodulename should then
disappear from theSheetscollection.

--
Rob Bovey, Excel MVP
Application Professionalshttp://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Developmenthttp://www.appspro.com/Books/Books.htm


Rob,

Thanks for the solution to fix the code. Now the question is, how can
one test if a member of the sheet colleciton is an old vbacodemodule?
Do you just do a test on type with an on error continue and test the
err.description or is there a better way?

Carl
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Code Module in Sheets Collection

wrote in message
...
Thanks for the solution to fix the code. Now the question is, how can
one test if a member of the sheet colleciton is an old vbacodemodule?
Do you just do a test on type with an on error continue and test the
err.description or is there a better way?


Hi Carl,

Assuming you're looping the sheets in something like the following
manner, you can use the TypeName function to check for modules. The only
time the type name "Module" will ever appear is if you've got an Excel 5/95
code module in the Sheets collection.

Dim objSheet As Object
For Each objSheet In ActiveWorkbook.Sheets
If TypeName(objSheet) = "Module" Then
MsgBox objSheet.Name & " is a legacy code module."
End If
Next objSheet

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Code Module in Sheets Collection

On Jun 3, 7:25 am, "Rob Bovey" wrote:
wrote in message

...

Thanks for the solution to fix the code. Now the question is, how can
one test if a member of the sheet colleciton is an old vbacodemodule?
Do you just do a test on type with an on error continue and test the
err.description or is there a better way?


Hi Carl,

Assuming you're looping the sheets in something like the following
manner, you can use the TypeName function to check for modules. The only
time the type name "Module" will ever appear is if you've got an Excel 5/95
code module in the Sheets collection.

Dim objSheet As Object
For Each objSheet In ActiveWorkbook.Sheets
If TypeName(objSheet) = "Module" Then
MsgBox objSheet.Name & " is a legacy code module."
End If
Next objSheet

--
Rob Bovey, Excel MVP
Application Professionalshttp://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Developmenthttp://www.appspro.com/Books/Books.htm


Rob,

Thanks a million, just what I needed!

Carl


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Code Module in Sheets Collection

On Jun 2, 1:11 pm, "Rob Bovey" wrote:
"CG" wrote in message

...

I am looping through allsheetsin a workbook and come across a sheet
that is named the same a one of thecodemodules and is
xlsheetveryhidden. I changed thecodemodulename with VBE and re-ran
thecode. The name changed to the new name. How could this be
possible?


I believe this is a very old workbook. Could this have anything to do
with macrosheets? The sheet does not have a codename.


This is typical of workbooks with VBAcodemodules that were created in
Excel 5/95. To convert themoduleinto a current versioncodemodule, the
easiest thing to do is to first make sure themodulehas a validcodemodule
name (no spaces or non alphanumeric characters). Then export themodule,
remove it from the project and import it back into the project. A new
versionmodulewill be created upon import and themodulename should then
disappear from theSheetscollection.

--
Rob Bovey, Excel MVP
Application Professionalshttp://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Developmenthttp://www.appspro.com/Books/Books.htm


Rob,

Thanks for the solution to fix the code. Now the question is, how can
one test if a member of the sheet colleciton is an old vbacodemodule?
Do you just do a test on type with an on error continue and test the
err.description or is there a better way?

Carl
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
User-defined type collection in class module Rob[_29_] Excel Programming 2 May 31st 06 06:02 PM
code in module A to not execute a Worksheet_SelectionChange sub of another module Jack Sons Excel Discussion (Misc queries) 4 December 11th 05 11:52 PM
Run worksheet module code from workbook module? keithb Excel Programming 1 August 14th 05 04:04 AM
creating a collection of Sheets references Eric[_27_] Excel Programming 1 February 6th 05 01:20 PM
collection of sheets mark Excel Programming 6 February 2nd 05 11:38 PM


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