Results 1 to 2 of 2

Thread: wildcard or regex pattern

  1. #1

    wildcard or regex pattern

    Hi all,

    well i'm looking for a wildcard or regex in vba pattern that can copy this number to a txt file (i have colored it with blue) from the whole code as i'm dealing with multiple html files and needs to get this number from

    i have attached a sample file contains the codes and the output txt file i'm supposed to get

    Many thanks in Advance for everyone that can help.

    Attached Files Attached Files

  2. #2
    Based on your example file, the following macro will extract the data. Change strPath to wherever you require the text file to be saved.

    Sub Macro1()
    Dim oPara As Paragraph
    Dim vLink As Variant
    Dim fso As Object
    Dim oFile As Object
    Const strPath As String = "C:\Path\Results.txt"
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set oFile = fso.CreateTextFile(strPath)
        For Each oPara In ActiveDocument.Paragraphs
            If Len(oPara.Range) > 5 Then
                vLink = Split(oPara.Range.Text, "%")
                oFile.WriteLine Replace(vLink(UBound(vLink) - 5), "2F", "")
            End If
        Next oPara
        MsgBox "Data extracted"
        Set fso = Nothing
        Set oFile = Nothing
        Set oPara = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes

Tags for this Thread

Posting Permissions

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