View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
CG[_4_] CG[_4_] is offline
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