View Single Post
 
Old 02-04-2014, 12:33 AM
mkhuebner mkhuebner is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Feb 2014
Posts: 7
mkhuebner is on a distinguished road
Default How to find and select text in a document?

I'm trying to create a Word 2010 macro that finds, selects, and reformats a single word in my document starting from the current cursor position. During recording of the macro, I've tried to use Find in the menu (Ctrl-F) but nothing is recorded in my macro for the find operation even though the cursor moves and highlights the found word. I've tried using the code below but that is also not moving the current cursor position to this word. Can somebody tell me how to record a Find text operation in a Word macro or else tell me what the correct VBA code is to do this? Thanks in advance!

Selection.Find.Text = "Synposis"
Selection.Find.Execute
Selection.Style = ActiveDocument.Styles("Body Text")
Selection.Font.Bold = wdToggle
Reply With Quote