Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

type name for vbcomponents?

Status
Not open for further replies.

venkman

Programmer
Oct 9, 2001
467
US
thread181-27567 outlines how to delete a code a module by using vbproject.vbcomponents.Remove() method. I would like to design a subroutine which deletes all macro code from a file. The problem is that vbcomponents contains items like sheets and thisworkbook. When you call remove() on a vbcomponent which is not a code module you get an error. How do you find out the type of vbcomponent you are looking at?

-Venkman
 
Use the "type" property. You'll want to remove all components that are not type=100, for example:

for each vbc in vbproject.vbcomponents
if vbc.type<>100 then vbc.remove
next vbc

Rob
[flowerface]
 
thanks for responding. Yeah I actually figured it out right after I posted. Meant to reply to my own query to close it, but I forgot. Oh, and the 100 is a listed constant also:
vbext_ct_Document

-Venkman
 
But the constant is not available unless you have the proper references set, so using the numeric value is easier sometimes...
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top