View Single Post
 
Old May 23rd, 2005, 09:20 AM
donaldmaloney donaldmaloney is offline
Registered User
 
Join Date: May 2005
Location: Manchester, CT, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Open Word Doc from Access - find, find next save

From Access I want to open a word Document. Search for text and then show a window where I can select the text I want to save to my database.
I have code that does this but it always starts at the top of the document. And
Shows the Last lines in the document if the find is not successful.

How can I open Word's Find window , show the document at the point of the find.
and then get the next result of the find?

I have the code that will select the data I want to save.
It's just getting the windows to open and close.
Plus if there is no success in the search I want to display a message.

Thanks

Any leads to point me in the right direction will help

Also the With WordObj.Selection.Find Now gives me an illegal Operation and Access closes down.
My Code:


On Error GoTo Err_Command3_Click
Dim WordObj As Word.Application
Dim ProposalName As String

' Start Microsoft Word and open the document.
Set WordObj = CreateObject("Word.Application")


DocumentName = "c:\" & Me.Parent.NameIDField & ".doc"
'Stop

WordObj.Documents.Open DocumentName, , ReadOnly:=True
' start at the first page of the document

'Stop
WordObj.Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst

'Stop
' search for the text
" BIHighlight is string
If BIHighlight = "" Then
BIHighlight = Me.BIField
Else
End If
With WordObj.Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
' .Execute FindText:="MoveMert"
'.Execute FindText:=Me.BIField.SelText
.Execute FindText:=BusinessIssueHighlight

End With

[Responses.Page] = WordObj.Selection.Information(wdActiveEndPageNumbe r)
Me.PageField.Requery
'Stop
' get the next nine sentences
With WordObj.Selection
.StartOf Unit:=wdParagraph, Extend:=wdMove
.MoveDown Unit:=wdParagraph, Count:=9, Extend:=wdExtend
End With
Debug.Print WordObj.Selection.Range
Me.ResponseField = WordObj.Selection.Range

'Stop
' Close and save the document.
'WordObj.ActiveDocument.Close SaveChanges:=wdSaveChanges
' go back to the start
' later try it without these next three lines

With WordObj.Selection
.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=4

End With

' Quit Microsoft Word and release the object variable.

WordObj.Quit SaveChanges:=wdDoNotSaveChanges


Set WordObj = Nothing

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub

Don