VBA Project Code

  • Thread starter Thread starter fi.or.jp.de
  • Start date Start date
F

fi.or.jp.de

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 ?
 
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(ModuleName).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 :
 
Back
Top