Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Search text for specific entry (2002)

    Hello All,
    I would like to search a memo field in a record for a text string like "file///NETWORKLOCATIONfile.ext". The field may have multiple entries of this type. Once it finds one, I want to capture the name and then move through the rest of the field. Does anyone have an idea how to do this?

    Thanks,
    Mark

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Search text for specific entry (2002)

    Since Windows allows file names with periods and spaces in them, and since extensions aren't necessarily 3 characters long (think .HTML and .JS), it is virtually impossible to know where a file name ends. A file name such as Myfile.doc Test.txt is perfectly acceptable. I wouldn't know how to determine whether Test.txt is part of the file name if it occurs in a long text string.

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Search text for specific entry (2002)

    Thanks Hans,
    I know it is bad to assume things when coding. However, this ties in with the file attachment thing I asked on an earlier thread. The utils or add ins I am looking at all put the file names in the body in a very uniform fashion. So, if I could search for the start of "file///" and then go to the line feed/carriage return, that would work. In my case, the files that they send will always have a three character extension like doc or jpg. Anyhow, how is it that I can search through the body to find this occurance?

    Thanks,
    Mark

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Search text for specific entry (2002)

    You could use the InStr function in code like this

    Dim strValue As String
    Dim intPos1 As Integer
    Dim intPos2 As Integer
    Dim strFile As String
    strValue = ... ' Assign field value here
    intPos1 = InStr(1, strValue, "file:///", vbTextCompare)
    Do While intPos1 > 0
    intPos2 = InStr(intPos1 + 8, strValue, vbCr)
    If intPos2 = 0 Then
    ' At end of string
    strFile = Mid(strValue, intPos1)
    ' Do something with filename
    Debug.Print strFile
    Exit Do
    Else
    strFile = Mid(strValue, intPos1, intPos2 - intPos1)
    ' Do something with filename
    Debug.Print strFile
    End If
    intPos1 = InStr(intPos2 + 1, strValue, "file:///")
    Loop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •