I want to use a VBA code module to do this, not the Find feature.
That is, I want to parse through all the VBA code and when I find an "OpenReport" statement I want to capture the name of the procedure which contains the statement to a file or table. I need to do this for both forms and reports.
Hmmmm I was thinking about that, and wondered if it was possible to search VBA using VBA and came up with this.
Dim M As AccessObject, dbase As Object, MD As Module
Dim lngStartLine As Long, lngBodyLine As Long, Find_This As String
Dim lngCount As Long, lngEndProc As Long, PR As String, A
Set dbase = Application.CurrentProject
Find_This = "Docmd" '<--- text you are looking for
For Each M In dbase.AllModules
If M.Name <> "module1" Then '<---name of my module - Put your module name here
Set MD = Modules(M.Name)
How_Many_Lines = MD.CountOfLines
For A = 3 To How_Many_Lines
If Left(MD.Lines(A, 1), 3) = "sub" Then PR = MD.Lines(A, 1)
If InStr(1, MD.Lines(A, 1), Find_This, vbTextCompare) Then
Debug.Print "< Procedure > "; PR; "< Line number > "; A; " < Code > "; Trim(MD.Lines(A, 1))
DoCmd.Close acModule, MD
Please note where I put your module name, I did this, as module1 was where this procedure was stored, if I didnt put this in, it would shut down the window I was running it in! If you remove it, then don't forget to take out that very last 'end if'
Does this answer part of problem ?? Still working on the insert bit...