Parsing a text file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Hulting
    New Member
    • Dec 2010
    • 13

    Parsing a text file

    I have the task of documenting about 80 different databases, I have mapped all the linked tables and host tables, in Visio with reverse engineering. Now I have to parse the code for all imports and exports and such. I have already extracted all the VBA code to .txt files and have condensed them to one file per database. Now I want to loop through the code to retrieve only the lines where, “acExport” is in the string, and hopefully return, DoCmd.TransferS preadsheet acExport, 8, "qry Manual_Item_Add s", "Path&File" , True, ""
    The acExport string will be a variable, but that should be a good example.

    As of right now, I get a line by line return starting at the first line.

    Thanks

    Andrew

    Code:
    Public Function fnFindText(foldername)
    Dim strSrTxt As String
    Dim A As String
    Dim fso As Scripting.FileSystemObject
    Dim f As Scripting.TextStream
          strSrTxt = "acExport"
    
                   Const ForReading = 1
    
             Set fso = CreateObject("Scripting.FileSystemObject")
             Set f = fso.OpenTextFile("XXXXX\Database Extracts\zzzMaster Code Files" _
     & "\" & foldername & " Master.txt", ForReading, True)
             Do While f.AtEndOfStream <> True
                A = f.readLine
               MsgBox (A)
                  If InStr(A, strSrTxt) <> 0 Then
                   boolStFnd = "True"
                   fnFindText = "Text found"
                               
             Exit Do
                End If
             Loop
             If boolStFnd <> "True" Then
                fnFindText = "Text not found"
             End If
             f.Close
            fnFindText = "File does not exists"
    
        End Function
    'Path to write temp files for extract into Visio
    ''''XXXXX\Knowledge base\Database Extracts\zzzMaster Extract Transfer
  • Andrew Hulting
    New Member
    • Dec 2010
    • 13

    #2
    Ok, I got it to work, I Commented out lines 16,17 and moved a 15 to line 19.

    Comment

    Working...