![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
I need to search a document for "words" that start with "32P". However, the numbering after the "32P" will be different (32P1, 32P2, 32P21, etc.). I can write a macro that finds all the "32P" occurrences by using a wildcard ("32P*"). However, I can't figure out how to get the full string (or full "word"). This is what I have so far:
Code:
Sub FindWords2()
sResponse = "32P*"
If sResponse <> "" Then
Application.ScreenUpdating = False
With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = sResponse
.MatchWildcards = True
' Loop until Word can no longer
' find the search string and
Do While .Execute
MsgBox Selection.Range.Text 'This only returns "32P" and not the whole string
Selection.MoveRight
Loop
End With
End With
Application.ScreenUpdating = True
End If
End Sub
|
| Tags |
| wildcard searches |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Check if a string is part of an array (containing wildcards...) | jodecaesteker | Excel Programming | 3 | 02-02-2018 10:56 AM |
Wildcards: searching for multiple words / expressions close to each other
|
ballpoint | Word VBA | 7 | 11-09-2017 03:30 PM |
| Searching for string on a formula | AMD2800 | Excel | 1 | 12-17-2014 10:41 AM |
Return entire program to default
|
blockie | Word | 2 | 04-13-2013 07:18 PM |
| Return Entire Row | ibrahimaa | Excel | 3 | 01-10-2012 05:44 AM |