Results 1 to 7 of 7

Thread: Copy text in a document with anchor

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    VBAX Regular
    Joined
    Apr 2007
    Posts
    41
    Location
    Sorry gmayor for the late reply, I was out of the country in vacations.

    What I intend to do is to put those found words in a userform textbox.

    Based on the last code you posted i developed the following code that works better for what I intend to do:

    Sub Macro99()
    Dim oRng As range
    Const strFind As String = "Modelo:^t" 
         
        Set oRng = ActiveDocument.range
        With oRng.Find
            Do While .Execute(FindText:=strFind)
                oRng.Collapse 0
                oRng.End = oRng.Paragraphs(1).range.End - 1
                            
                If Left(oRng.Text, 9) = "IFC 100 W" Or _
                   Left(oRng.Text, 9) = "IFC 100 C" Or _
                   Left(oRng.Text, 9) = "IFC 070 C" Or _
                   Left(oRng.Text, 9) = "IFC 070 F" Or _
                   Left(oRng.Text, 9) = "IFC 050 C" Or _
                   Left(oRng.Text, 9) = "IFC 050 W" Or _
                   Left(oRng.Text, 9) = "IFC 300 W" Or _
                   Left(oRng.Text, 9) = "MAC 100" Or _
                   Left(oRng.Text, 17) = "OPTISENS ODO 2000" Or _
                   Left(oRng.Text, 13) = "Optiflux 2000" Or _
                   Left(oRng.Text, 17) = "SMARTPAT ORP 1590" Or _
                   Left(oRng.Text, 16) = "Waterflux 3000 F" Or _
                   Left(oRng.Text, 13) = "Optiflux 1000" Or _
                   Left(oRng.Text, 15) = "Optiflux 2000 F" Then
                    GoTo 1
                End If
                      MsgBox oRng.Text
    1:
              oRng.Collapse 0
            Loop
        End With
    lbl_Exit:
        Set oRng = Nothing
        Exit Sub
    End Sub
    Just one more question: Could we find more than one word?
    Last edited by dzogchen; 08-07-2019 at 07:46 AM.
    Microsoft 2010 | VBA 7.1

Posting Permissions

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