Import WILDCARD search to EXCEL from WORD

T

Tweedy

I've browsed the groups and managed to get the code below working to a point.
I'm using OFFICE 2002 and trying to search club minutes done in WORD looking
for motions that were made at meetings.
Once found the paragraph before the search text and the searched text is
imported in two separate strings to EXCEL where the macro resides. The
string always starts with "(M" and ends with ")" and also ends a paragraph.
I've tried Regular expressions and using wildcards to no avail. Would sure
like some help directly with code or a pointer to a reference on how to do
this.


~~~ CODE SNIPET ~~~
Sub MotionFinder()
Dim sPth As String
Dim sNam As String
Dim oWrd As Object
sPth = "c:\motion\"
col = 1
Row = 2
s_counter = 42

Set oWrd = CreateObject("Word.Application")
' Set oWrd = GetObject(, "Word.Application")
oWrd.Visible = True
sNam = Dir(sPth & "*.doc")
While sNam <> ""
'Range("C1").Value = s_counter
oWrd.documents.Open sPth & sNam 'Open Minute documents 1 at a time
Dim rDcm As Object
Set rDcm = oWrd.activedocument.Range ' Search all
With rDcm.Find
.Text = "(M" ' Find a motion NEED WILDCARD TO FIND ALL
While .Execute ' Select the motion
rDcm.Select
Range("A" & Row).Value = rDcm
Row = Row + 1
s_counter = s_counter + 1

Wend
End With
oWrd.activedocument.Close
sNam = Dir
Wend
oWrd.Quit
Set oWrd = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top