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

How Do I Delete a Word VBA Module and Form

Status
Not open for further replies.

PBAPaul

Programmer
Aug 3, 2002
140
GB
I need to distribute a new module and associated form to various people.

I know that an old version e.g. 'Old_Module' and 'Old_Form' exists on some machines and I want to delete both of these (if they exist) from the existing Normal template before adding my 'New_Module' and 'New_Form'.

Please can anyone tell me how to do this?

Thanks

Paul
 
Add a reference to Microsoft Visual Basic for Applications Extensibility, this will allow you to expose the objects. Here is a hastily constructed sample that removes [tt]mdlTest2[/tt] from my project:
Code:
Public Sub RemoveModule()
Dim objProj As VBProject
Dim objComponent As VBComponent
Set objProj = VBE.ActiveVBProject
Set objComponent = objProj.VBComponents("mdlTest2")
objProj.VBComponents.Remove objComponent
Set objProj = Nothing
End Sub
You should be able to remove a form by replacing mdlTest2 with the name of your form.

Hope this helps,
CMP

Instant programmer, just add coffee.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top