Consulting

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

    https://web.atms.a2z.com/web/login/a...ation%2Fjob%2F12732403%3FmemsourceServerUrl%3Dhttps%3A%2F%2Fatms.a2z.com

    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.

    Cheers
    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
    
    
        oFile.Close
        MsgBox "Data extracted"
    lbl_Exit:
        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
    http://www.gmayor.com

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
  •