VBIDE coding - User defined type not defined error

staticbob

Well-known Member
Joined
Oct 7, 2003
Messages
1,079
Guys,

I'm using the code below from Chip Pearsons site to removed all code on a worksheet that I'm copying. I'm getting this user defined type not defined error on the first line . . any ideas ?

Thanks
Bob

Sub FUBARVBA()

Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents

Set VBComps = ActiveWorkbook.VBProject.VBComponents

For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp

End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You need to add a reference to the VBA extensibility library. Click on Tools-References in the VBE, and scroll down and tick the entry for Microsoft Visual Basic for Applications Extensibility 5.3.
 
Upvote 0
Thanks Mud,

But now I get a type mismatch on . . .

Set VBComps = ActiveWorkbook.VBProject.VBComponents


?

Cheers,
Bob
 
Upvote 0
I'm not sure why you'd get a type mismatch, it works OK on my PC. You may run into problems if you're running Excel 2002 or above, you need to click on Tools-Macros-Security and the Trusted Sources tab, then check the Trust Access to Visual Basic Project box.
 
Upvote 0
nah, Im running XL2000 Mud so the trusted sources doesn't apply I presume ?

Cheers
Bob
 
Upvote 0

Forum statistics

Threads
1,215,049
Messages
6,122,864
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top