Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to open a MS Word document stored in Access 2000 as an ole object

Status
Not open for further replies.

beruken

Programmer
Mar 12, 2002
22
0
0
US
I am interested in knowing how to open a MS Word document stored in Access 2000 as an ole object. I get "type mismatch" error with the following code..

Dim oRst, sQuery
Set oRst = CreateObject("ADODB.Recordset")
sQuery = "Select * FROM tblPOW WHERE tblPOW.[Current] = true"
oRst.Open sQuery, oConn

Dim WordApp
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = TRUE
WordApp.Documents.Open(oRst("news"))

If .Open method doesn't work what method will work?
 
Try using the ActiveX control Microsoft Web Browser. Insert it into your form and then in the OnOpen event (or whatever) of the form, set the navigation property. For example, suppose you name the ActiveX contrl axWebBrowser. In the OnOpen event do something like this:

axWebBrowser.Navigate = "\\path\yourWordDocument.doc"

Off hand, I'm not sure if the = sign is neccessary.
 
How about this ?
oRst("news").Action = acOLEActivate '7
Set objWord = GetObject(, "Word.Application")
or perhaps:
Set objWord = oRst("news").Application

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
What do your references have to include?
I set OLE object and MS Word Object Library
and many others but they don't seem to "work".

I have the following code, but the Word.Application
is not capitalized and is not recognized yet,
so my wd. object doesn't have any linked properties.


Dim db As database
Dim rs As Recordset
Dim wd As Object

Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_doc")
Set wd = CreateObject("word.application")
 
I've done it by referring to a hidden bound object frame on a form:

Forms!YourForm!YourObject.Verb = acOLEVerbOpen
Forms!YourForm!YourObject.Action = acOLEActivate
 
I used Rick39's suggestion above, but as my document contained a mail merge, the acOLEActivate failed.

Instead, I was able to get it to work by using the following code (replacing the acOLEActivate with acOLEVerbShow):
Code:
    With Forms!frmMailMerge!OLEUnbound0
        .Verb = acOLEVerbShow
        .SaveAs "C:\Temp\SaveLocation.doc"
    End With
Can anyone explain why this works?

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top