Open Word with Find Parameter

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

I have created a database for our secretary that includes
all of the headings from our board meeting packets and the
date of the board meeting. You can enter a keyword and
search the headings to get a list of board meetings the
topic was discussed at. You can then click on any heading
in the list to open the board packet in MS Word.

Our General Manager loves it, but now wants Word to open
directly to the paragraph with the keyword in it. I used
the Shell Function to open the file as follows:

x = shell("winword.exe filename.doc", 3)

Is there any way I can make the file open with the
menuitem edit/find opened with the keyword being used so
the word file will open straight to the correct paragraph?
 
Over lunch I figured out how to solve it with the
following code, just in case anyone was working on it.

Dim SendStr As String
SendStr = "{F10}{TAB}{ENTER}F" &
Forms.MainMenu.keyword & "{TAB}{TAB}{ENTER}{TAB}{ENTER}"
SendKeys SendStr, False

Thanks to all who tried to help.
 
Yes. Try the following (I did this MS Access, which is
what I assume you're using):

Dim schText As String
Dim theFile As String
Dim wordApp As Object

theFile = "full path and name of document"
schText = "text to search for"


Set wordApp = CreateObject
("Word.application") 'start MS Word
wordApp.Documents.Open
(theFile) 'open the fie

wordApp.Selection.Find.ClearFormatting 'clear
the find options
wordApp.Selection.Find.Text =
schText 'pass the text to search for

wordApp.Selection.Find.Execute 'do
the search
wordApp.Application.Visible =
True 'make Word visible

wordApp.Activate 'make
Word the Active window
Set wordApp =
Nothing 'clean up
 
Thanks!

This way works much better. The way I came up with made
the screen "bounce" a little while it went through the
commands. This is much cleaner.
 
Back
Top