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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove a module 1

Status
Not open for further replies.

AgatheB

Programmer
Jan 16, 2003
36
DK
Hi,
I'm trying to remove a module in excel, but i keep getting errors (438). The code I'm using is:
Workbooks(Books_to_do(1)).VBProject.VBComponents(4).Remove

But I've also tried:
Set Old_project = Workbooks(Books_to_do1)).
VBProject.VBComponents(Sheets(I).Name)
Old_project.remove

And:
For Each M In Workbooks(Books_to_do1)).
VBProject.VBComponents
If M.Type = 1 Then
If M.Name = Sheets(I).Name Then
M.Remove
End If
End If
Next

I hope there's someone that can help me with this.
Agathe
 
The syntax to remove component is:
[tt]...VBProject.VBComponents.Remove objVBComponent[/tt]
where objVBComponent is component reference you want to delete.

Nb., you can't delete modules associated with sheet, workbook or form.

combo
 
Thanks combo!

One star earned by you.

Agathe
 
Thanx Agathe for the star. Obviously, one can remove user form with the above code.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top