|
-
Apr 27th, 2012, 09:32 AM
#1
Thread Starter
New Member
[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
-
Apr 29th, 2012, 09:38 AM
#2
Fanatic Member
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.
-
Apr 29th, 2012, 10:00 AM
#3
Thread Starter
New Member
Re: [Word] How to close "Search item not found" dialog
Thank you, dmaruca. I appreciate your help.
 Originally Posted by dmaruca
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|