Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello--I have written a simple macro trying to find and select certain
text in a word document (it is part of a larger project). When the macro is finished running, I would like word to have the first instance of the text selected. However, the following code is not doing the job. I am sure I am missing something simple. Can anyone help? -Abe Sub find() Set wdapp = GetObject(, "Word.Application") Set wddoc = wdapp.ActiveDocument With wddoc.Content.find .Text = "Q1" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchAllWordForms = False .Execute (findtext = "Q1") End With End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This one is actually embarrassingly simple. I am missing the statement
Selection.Find.Execute at the end of the find code. I guess the find property needs an additional step to be completed. The working code goes: Set wdapp = GetObject(, "Word.Application") Set wddoc = wdapp.ActiveDocument With wddoc.Content.find .Text = "Q1" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchAllWordForms = False .Execute (findtext = "Q1") End With selection.find.execute End Sub wrote: Hello--I have written a simple macro trying to find and select certain text in a word document (it is part of a larger project). When the macro is finished running, I would like word to have the first instance of the text selected. However, the following code is not doing the job. I am sure I am missing something simple. Can anyone help? -Abe Sub find() |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding a single word match in a text string and assigning a code | Excel Worksheet Functions | |||
Excel 2007 B2 - Selecting every cell that starts with a certain word | Excel Discussion (Misc queries) | |||
Finding a cell, selecting the one down | Excel Programming | |||
Finding read-only & pwd protection attibutes of Word & Excel files | Excel Programming | |||
Finding Words In Excel Spreadsheets & Word Documents | Excel Discussion (Misc queries) |