Results 1 to 3 of 3

Thread: [Word] How to close "Search item not found" dialog

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    2

    [Word] How to close "Search item not found" dialog

    I am searching for text within a selection that may or may not exist. If it does not exist I need a way to close the resulting error dialog. In Word I can press the keyboard shortcut "Alt+N", but I can't find a way to code a key combination in the help files. Here's what I have so far. I'm a noob to this so any other suggestions are also appreciated.

    Andy

    Code:
        Selection.Find.ClearFormatting
        With Selection.Find
            .Text = "[END]"
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute
        ' Move cursor to end of line
        Selection.MoveRight Unit:=wdCharacter, Count:=1
        ' Select from [END] to top of page
        Selection.HomeKey Unit:=wdStory, Extend:=wdExtend
        ' Find "Name" in current selection
        Selection.Find.ClearFormatting
        With Selection.Find
            .Text = "User="
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        ' Find.Execute2007
        If (Selection.Find.Execute) = True Then
            ' Extend selection to end of line and copy to "Parsed" document
            Selection.EndKey Unit:=wdLine, Extend:=wdExtend
            Selection.Copy
            Windows("symlib_Parsed.docx").Activate
            Selection.EndKey Unit:=wdLine
            Selection.PasteAndFormat (wdPasteDefault)
            Windows("symlib.txt").Activate
            Selection.MoveRight Unit:=wdCharacter, Count:=1
        Else
            ' Press keyboard shortcut "Alt+N" to close error dialog
            
        End If

  2. #2
    Fanatic Member dmaruca's Avatar
    Join Date
    May 2006
    Location
    Jacksonville, FL
    Posts
    577

    Re: [Word] How to close "Search item not found" dialog

    You don't need to program in a sendkeys hack. It's basically prompting because you told it to. Change this line to be either wdFindContinue or wdFindStop depending on whether you want to search the entire document or not.

    Code:
    .Wrap = wdFindAsk

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    2

    Re: [Word] How to close "Search item not found" dialog

    Thank you, dmaruca. I appreciate your help.

    Quote Originally Posted by dmaruca View Post
    You don't need to program in a sendkeys hack. It's basically prompting because you told it to. Change this line to be either wdFindContinue or wdFindStop depending on whether you want to search the entire document or not.

    Code:
    .Wrap = wdFindAsk

Posting Permissions

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



Click Here to Expand Forum to Full Width