moving files of ole objects

M

Miguel

Hi,
I 've a table with linked OLE objects.
Now I moved the files to another location.
How can I tell my ms-access 2000 db to change all location of ole objects
in my table.
I tried following code, but it doesn't seem to work.
acOLEUpdate doesn't seems to work as I expeted.
And this code still requires to open WORD :-(
"
'
Sub tst()
Dim frmName As String, fldName As String, replName As String
Dim frm As Form
Dim rsTbl As Recordset
Dim wrd1 As Object

'fill in some names...

DoCmd.OpenForm frmName
Set frm = Forms(frmName)
Set rsTbl = frm.RecordsetClone
rsTbl.MoveFirst
'start loop here

'sync form with recordset
frm.Bookmark = rsTbl.Bookmark
With frm(fldName).Object
.Action = acOLEActivate
Set wrd1 = GetObject(, "Word.Application")
rsTbl.Edit
'.Class = "Word.Document"
.OLETypeAllowed = acOLELinked
.SourceDoc = replName ' new doc name
.Action = acOLEUpdate ' try to update link to my doc

rsTbl.Update
End With
rsTbl.MoveNext
'end loop
End Sub
"

Any help would be appreciated.

Thanks,
Miguel
 
A

Alex Ivanov

The easiest way is to put the files back to their original location. If that
not possible, you may re-create the ole objects
with something like this (if you know the file names of linked objects):

OLEBound0.SourceDoc = ActualPathToDoc
OLEBound0.Action = acOLECreateLink

If you didn't store the filenames of linked docs elsewhere in the database,
then it would be very difficult to resolve the problem.
You will need to binary read the OLE Headers from the object fields and use
Windows API functions to parse the filenames.
See this example of what the OLE headers look like. You will need NameOffset
and NameLen to get the file name.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;147727

IMO, the better solution would be to get rid of oleobjects at all and store
only paths to the files in the database.
 

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