Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Wellington, New Zealand
    Thanked 1 Time in 1 Post

    Find and Replace settings (Word 97)

    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).
    <img src=/S/help.gif border=0 alt=help width=23 height=15>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: Find and Replace settings (Word 97)

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

    <pre>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</pre>

    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.

Posting Permissions

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