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

How to alter existing code in module with VBA? 1

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
US
I remember, seeing in the past, a way to locate a section of code in a module. Once found, it is possible to alter it using VBA. Wow! Can anyone help?

Steve
 
Some notes.

Code:
Sub EditClassMods(frmname)
Dim mdl As Module
Dim strLine, strLineChk
strLineChk = "To be sure"
acApp.DoCmd.OpenForm frmname, acDesign, , , , acHidden

If acApp.Forms(frmname).HasModule Then
    Set mdl = acApp.Forms(frmname).Module
    strLine = Trim(mdl.Lines(16, 1))
    If strLine = strLineChk Then
        mdl.DeleteLines 16, 1
        mdl.InsertLines 16, vbTab & "Insert This"
        mdl.InsertLines 17, vbTab & "And This"
    Else
        MsgBox "There is a mismatch somewhere."
    End If
Else
    MsgBox "Error: No Module"
End If

Set mdl = Nothing
acApp.DoCmd.Close acForm, frmname, acSavePrompt

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top