Coding to remove and import Module

  • Thread starter Thread starter mathieu936
  • Start date Start date
M

mathieu936

Hi!

I would like to remove a VB module and import an other one each time I
open my excel file. Thus I need the code to put in my Sub Auto_Open()
to remove and import a module.

I just hope these codes exist!
 
Try something like

Sub Auto_Open()
On Error Resume Next
With ThisWorkbook.VBProject.VBComponents
.Remove .Item("modToReplace")
.Import Filename:="C:\Test\modToReplace.bas"
End With
End Sub

See www.cpearson.com/Excel/VBE.aspx for much more information about working
with the objects in the VBA Editor.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
Excellent! Works great! Thanks!

Now I have text in a Notepad document and I would like it to be copied
in a cell once the module is copied. Which code can I use to do this?
 
Back
Top