Results 1 to 13 of 13

Thread: Macro to pick information from notepad

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,273
    Location
    Hi sheku,

    Try the following. Modify the "Drive:\FilePath\FindReplaceList.doc" string to point to your source document holding the Find/Replace list.
    Sub BulkFindReplace()
    Application.ScreenUpdating = False
    Dim FRDoc As Document, FRList As String, j As Long
    'Load the strings from the reference doc into a text string to be used as an array.
    Set FRDoc = Documents.Open("Drive:\FilePath\FindReplaceList.doc")
    FRList = FRDoc.Range.Text
    FRDoc.Close False
    Set FRDoc = Nothing
    With ActiveDocument.Range.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .MatchWholeWord = True
      .MatchCase = True
      'Process each word from the Check List. Tab-delimited strings are assumed, formatted as:
      'Find text <Tab> Replace text
      For j = 0 To UBound(Split(FRList, vbCr)) - 1
        .Text = Split(Split(FRList, vbCr)(j), vbTab)(0)
        .Replacement.Text = Split(Split(FRList, vbCr)(j), vbTab)(1)
        .Execute Replace:=wdReplaceAll
      Next
    End With
    Application.ScreenUpdating = True
    End Sub
    Last edited by macropod; 01-26-2021 at 09:16 PM.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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