QUESTION

  • Thread starter Thread starter Ted via AccessMonster.com
  • Start date 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! : - )
 
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"
 
So what does the Loop look like? How do I "loop through each line" ?

Thank you : )
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top