View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
FS[_2_] FS[_2_] is offline
external usenet poster
 
Posts: 2
Default VBA Project Code

Hi,

Try this code :

'==================
Sub test()
''''''''for example
Wbk$ = "MEFC_Dates.xla"
ModName$ = "usfParams"
Before$ = "Unload usfParams"
After$ = "Unload me"
'''''''''''''''''
ChangeCodeVBA Wbk, ModName, Before, After
End Sub

Sub ChangeCodeVBA(WbkName, ModuleName, BeforeChange, AfterChange)
Dim S$
With Workbooks(WbkName).VBProject.VBComponents(ModuleNa me).CodeModule
On Error Resume Next
S = .Lines(1, .CountOfLines)
.DeleteLines 1, .CountOfLines
On Error GoTo 0
S = Join(Split(S, BeforeChange), AfterChange)
.AddFromString S
End With
Workbooks(WbkName).Save
End Sub 'fs
'==================

FS
--
Frédéric SIGONNEAU
Modules et modèles pour Excel :
http://frederic.sigonneau.free.fr/

fi.or.jp.de a écrit :
Hi All,

I have excel based tracker. All the macro part working fine.

Problem is I sent the file to all the users.

Small mistake I made in Macro part ie.,

instead of Uform.optionbutton1 = true I put that one as
Uform.optionbuttion2 = true.

I need to change only one line code in the module.

I can send new excel file ? but I am learning how to change the module
codes using macro.

Any suggestions ?