painful ole object problem

  • Thread starter Thread starter con
  • Start date Start date
C

con

Hi,

Is there anyway to perform a search on an embedded word
docuemnt, i.e if I have 100 word documents stored in
access 2002, I want to be able to search on all documents
that contain, "February", or something like that.


Thanks in advance
 
Perhaps a better approach would be to save just the filenames in the
database - not the actual documents. This would reduce the size of your
database, & you could write code to open each file in turn, & search it,
using Word from Access.

Something like this (untested):

dim oWord as object, db as database, rs as recordset
' start Word.
set oWord = createobject ("Word.Application")
' open table.
set db = currentdb()
set rs = db.openrecordset ("SELECT WordDocNameField FROM MyTable")
' loop through table.
while not rs.eof
' now use methods of the oWord object to open & search the document.
oWord.open rs![WordDocNameField]
...
rs.movenext
wend
set rs = nothing
set db = nothing
oWord.quit ' quit? close? exit?
set oWord = nothing

There are probably some typos in that, but you get the idea, no?

HTH,
TC
 
Hi there
thanks for the reply

I have done a test, created a table called table 1, with an autonumber ID and a field called "CV" which is a hyperlink to a cv on my c drive
I create the form and all is fine
I put a button on the form with the following code as you gave and this error occurs "type mismatch". It stops at the select statement. Your help in this is much appreciated

regard
Co

dim oWord as object, db as database, rs as recordse
' start Word
set oWord = createobject ("Word.Application"
' open table
set db = currentdb(
set rs = db.openrecordset ("SELECT cv FROM Table1"
' loop through table
while not rs.eo
' now use methods of the oWord object to open & search the document
oWord.open rs![cv
..
rs.movenex
wen
set rs = nothin
set db = nothin
oWord.quit ' quit? close? exit
set oWord = nothin
 
The code looks ok to me. Could you cut & paste it directly from your
program, and reply with that? The code below is definitely not cut & pasted
from your own program.

You say that cv is a hyperlink. To use my code, cv should be a text field
containing the full path to the document: for example, "C:\My
Documents\cv.doc" or whatever. However, the field type is not what is
causing the SELECT to fail. Show me your actual (cut & pasted) code

HTH,
TC


con said:
Hi there,
thanks for the reply,

I have done a test, created a table called table 1, with an autonumber ID
and a field called "CV" which is a hyperlink to a cv on my c drive.
I create the form and all is fine.
I put a button on the form with the following code as you gave and this
error occurs "type mismatch". It stops at the select statement. Your help in
this is much appreciated.
regards
Con


dim oWord as object, db as database, rs as recordset
' start Word.
set oWord = createobject ("Word.Application")
' open table.
set db = currentdb()
set rs = db.openrecordset ("SELECT cv FROM Table1")
' loop through table.
while not rs.eof
' now use methods of the oWord object to open & search the document.
oWord.open rs![cv]
...
rs.movenext
wend
set rs = nothing
set db = nothing
oWord.quit ' quit? close? exit?
set oWord = nothing
 
Hi there,
here's what I have now and word perfectly for me barr 1 thing

Dim perlico As DAO.Databas
Dim rstCustomers As DAO.Recordse
Set perlico = CurrentDb(
Set rstCustomers = perlico.OpenRecordset("Table1", dbOpenDynaset

With rstCustomer
Me.cv.SetFocu

Do While Not .EO

Dim fname As Strin
cv.SetFocu
fname = cv.Tex



Dim WordObj As Objec
Set WordObj = CreateObject("Word.Application"
WordObj.Visible = Tru
WordObj.Documents.Open filename:=fnam

WordObj.Selection.Find.ClearFormattin
WordObj.Selection.Find.Text = Text5.Valu




If WordObj.Selection.Find.Execute = True The
MsgBox "found
Els
MsgBox "not found
WordObj.Qui
End I



DoCmd.GoToRecord acDataTable = acDataTable, "Table1", acNex
rstCustomers.MoveNex

Loo
End Wit


what I would like to do is search the document for multiple criteria and not just one

I've tried the following but does not wor

WordObj.Selection.Find.Text = Text5.Value or text7.valu

your help is much appreciated again

cheers
 
Con, you're losing me. You said that your code failed with a type mismatch
error. I asked you to post the actual code. Now you imply (but do not say)
that the error has gone away.

Are you still getting a type mismatch error? If so, on what line does it
occur?

TC
 
Back
Top