• Find and Replace settings (Word 97)

    • This topic has 1 reply, 2 voices, and was last updated 23 years ago.
    Author
    Topic
    #370219

    Can anyone tell me where the content of Selection.Find.Text is stored between uses of Find and Replace in Word? I want to retrieve and use the content in a dialog box, but with no active document (a documents count of 0).
    help

    Viewing 0 reply threads
    Author
    Replies
    • #585109

      I can’t see any way to do it, except to temporarily create a hidden document:

      Function GetLastFind() As String
      Dim docTemp As Document
      Set docTemp = Documents.Add(Visible:=False)
      With docTemp
          .Activate   'avoids error on next line
          GetLastFind = Selection.Find.Text
          .Close SaveChanges:=wdDoNotSaveChanges
      End With
      Set docTemp = Nothing
      End Function
       
      Sub TestLastFind()
      MsgBox GetLastFind
      End Sub

      Note: I could not retrieve the user’s find text with the Range object.

      If you want to return a richer set of properties, you could put together a little data structure of your own, or insert your logic into the Function to return a tailored message string. However, you cannot pass the object back to the calling procedure because it becomes invalid once the hidden document is closed.

      Note: tested in Word 2000.

    Viewing 0 reply threads
    Reply To: Find and Replace settings (Word 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: