QUESTION

  • Thread starter Ted via AccessMonster.com
  • Start date
T

Ted via AccessMonster.com

Hey everone!

Is it possible to programmatical insert my initials " - TDE" at the end of
each comment line (each line in the module beginning with ' ) ?

Thank you for any help! : - )
 
D

Douglas J. Steele

You can use the ReplaceLine method of the Module object.

You need to open the module, then loop through each line, looking for ' at
the beginning (don't forget that there can be white space in front of the ',
so use the LTrim function to remove any preceding blanks). When you find a
comment, use ReplaceLine to replace what's there with what's there & " -
TDE"
 
T

Ted via AccessMonster.com

So what does the Loop look like? How do I "loop through each line" ?

Thank you : )
 
D

Douglas J. Steele

Try something like the following untest aircode:

Sub ListLines()
Dim dbCurr As DAO.Database
Dim docCurr As DAO.Document
Dim mdlCurr As Access.Module
Dim lngCurr As Long
Dim lngMax As Long
Dim strCurrLine As String
Dim strModuleName As String

Set dbCurr = CurrentDb()
For Each docCurr In dbCurr.Containers("Modules").Documents
strModuleName = docCurr.Name
DoCmd.OpenModule strModuleName
Set mdlCurr = Modules(strModuleName)
lngMax = mdlCurr.CountOfLines
For lngCurr = 1 To lngMax
strCurrLine = mdlCurr.Lines(lngCurr, 1)
If Left(LTrim(strCurrLine), 1) = "'" Then
mdlCurr.ReplaceLine lngCurr, strCurrLine & " - TDE"
End If
Next lngCurr
DoCmd.Close acModule, strModuleName, acSavePrompt
Next docCurr
Set dbCurr = Nothing

End Sub
 
Top