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

How to delete a vba module in excel XP

Status
Not open for further replies.

leassaf

Instructor
May 20, 2001
49
IL
Hey Guys!
In excel 97 (maybe even in 2000) it was possible to delete a module programmatically by using something such as :

Application.VBE.ActiveVBProject.VBComponents.Remove _ Application.VBE.ActiveVBProject.VBComponents("ModuleName")

I couldn't do it in Excel Xp anymore.

Someone???
 
Hi, get some ideas from this Function

***NOT TESTED*****

Function CopyVBEComponent(vbpSourceProject As VBIDE.VBProject, _
vbpDestProject As VBIDE.VBProject, _
strComponent As String)
' Copy VBE component to another workbook's project.

Dim vbcExport As VBComponent
Dim strFileName As String

' Check whether component already exists in project.
' Copy to destination project only if it does not exist.
If ComponentExistsInProject(vbpDestProject, strComponent) = False Then
' Return reference to component to export.
Set vbcExport = vbpSourceProject.VBComponents(strComponent)
' Construct name for exported file.
strFileName = ThisWorkbook.Path & "\" & vbcExport.Name
' Export component from exporting project.
vbcExport.Export strFileName
' Import component into project.
vbpDestProject.VBComponents.Import strFileName
' Delete file.
Kill strFileName
End If
End Function Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top