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




Reply With Quote