Open OLE from Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I referecnce a docment stored in an OLE field?

I want to have a user click "Print to word" which creates a word document
based on a template stored in a table. Since the user may not have a network
connection and i want the Access application to be 'self contained' (nothing
but the *.mdb file), the template must be stored in a table.

I can add to and delete from the OLE field using VB; however, opening a
document does not seem to happen:

Set obj = rds.Fields("oleTemplate").Value
Set docWord = appWord.Documents.Add(obj)

The Add method is looking for path\file.name convetion, and not an object.
I saw how to use form based control, but i do not think this will allow me to
open word etc...

Thank you for your help...
 
This method works for putting all sorts of documents into an ole field
(stored insside the mdb)

my ole field is called original_doc which is accessed through a form.

to store the doc you use

Frm.Original_Doc.SourceDoc = sFileName
Frm.Original_Doc.Action = acOLECreateEmbed

to read the doc out using the original application use:

Frm.Original_Doc.Verb = acOLEVerbShow
Frm.Original_Doc.Action = acOLEActivate

In my app the ole control is hidden norrmally , I have to make the conntrol
visible before storing or showing and can then make it invisible again
immediately.

Peter Snape
 
I should have been more specific: i am trying to use a recordset to get the
OLE object and not use a form. I very much would like to not use any type of
form to get the information.

' set reference to MS Word.
On Error Resume Next
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then Set appWord = CreateObject("Word.Application"):
Err.Clear

appWord.Visible = True

' Open a new document from the template
Set rds = CurrentDb.OpenRecordset("tblAppTemplates")
Set docWord = GetObject(rds!Fields("oleTemplate")) ' this line does not
function properly
 
Also, the OLE Object in the table, tblAppTemplate, can NOT be modified.

(i tried Peter's method and and I was able to open the document and save it
to disk, but the OLE Object had changed. I don't want to make the table
un-updateable and use error handling for this)
 

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

Back
Top