Guest User

Untitled

a guest
Jan 16th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Public Sub AutoFind()
  2. On Error GoTo myErrorHandler
  3.  
  4. Selection.HomeKey Unit:=wdStory
  5.  
  6. Dim theDialog As dialog
  7. Set theDialog = Application.Dialogs(wdDialogEditReplace)
  8. theDialog.Find = "the"
  9. theDialog.replace = "an"
  10.  
  11. theDialog.Show
  12. End Sub
  13.  
  14. Sub TestMacro()
  15. Selection.Find.ClearFormatting
  16. Selection.Find.Replacement.ClearFormatting
  17. With Selection.Find
  18. .Text = "test find field"
  19. .Replacement.Text = "test replace field"
  20. .Forward = True
  21. .Wrap = wdFindContinue
  22. .Format = False
  23. .MatchCase = False
  24. .MatchWholeWord = False
  25. .MatchWildcards = False
  26. .MatchSoundsLike = False
  27. .MatchAllWordForms = False
  28. End With
  29.  
  30. CommandBars.FindControl(ID:=313).Execute
  31. end sub
  32.  
  33. SendKeys "^h" ' Hack to obtain "Dialogs(wdDialogEditReplace).Show" modelessly.
  34. ' MS Disclaimer: SendKeys is unreliable as to there being no certainty as to where focus is when called.
Add Comment
Please, Sign In to add comment