How to Rename a module using VBA code

A

allissonlu

When the Excel project is active, how can I rename one of the project'
module. Saying that I have a module named "parameters", I exported thi
module and then deleted it. At this time, the excel workbook is stil
open and active and I want to import the same module. How can I d
this?

It doesn't work although i tried several methods. It seems the modul
is still in memory although it disappear in the VBA view of th
project.

Can somebody help me on this? I REALLY REALLY need to solve thi
emergence very soon. Please please help me.

Allisso
 
B

BrianB

Hopefully this will help. Modules can only be imported via .txt or .ba
files.


Code
-------------------

'========================
'-REPLACE CODE MODULE
'========================
Sub ModuleReplace()
Dim FName As String
Dim iMod As Object
'---------------------------------------------
'- REMOVE OLD
Set iMod = ActiveWorkbook.VBProject.VBComponents
iMod.Remove VBComponent:=iMod("UPLOADER")
'- EXPORT REPLACEMENT TO FILE
With Workbooks("Journal_Macros.xls")
FName = .Path & "\code.txt"
.VBProject.VBComponents("uploader").Export FName
End With
'- IMPORT FILE
iMod.Import FName
End Sub
'=============================================
 
J

jaf

Hi,
Did you delete it from the disk or the editor?
If it's on the HD just open it with notepad and copy & paste.


--

John
johnf202 at hotmail dot com



: When the Excel project is active, how can I rename one of the project's
: module. Saying that I have a module named "parameters", I exported this
: module and then deleted it. At this time, the excel workbook is still
: open and active and I want to import the same module. How can I do
: this?
:
: It doesn't work although i tried several methods. It seems the module
: is still in memory although it disappear in the VBA view of the
: project.
:
: Can somebody help me on this? I REALLY REALLY need to solve this
: emergence very soon. Please please help me.
:
: Allisson
:
:
: ---
:
:
 
Top