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!

Open word doc stored in Access as 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 with vbscript. I get t 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"))
 
Set Word = CreateObject("Word.Application")
Word.Visible = TRUE
Word.Documents.Open("C:\My Documents\myfile.doc")

the above is from a FAQ on this site.
Does this code work for you?
if it does then oRst("news") probably doesnt represent a string,
i.e.
If Not IsNull(oRst("news")) Then
and/or
CStr(oRst("news"))
and/or
If Not IsArray(oRst("news")) Then

, some defensive programming might help you out,

if not tell us which line is causing the error, if the provider tells you of course

good luck
 
Thanks for your response. Yes the recordset value does not represent a string. It is an acutal document stored as an ole object in the database and the error "type mismatch" is correct. What I don't understand is how to use the word.application object to open a stored word document in MS Access.
 
How about this ?
oRst("news").Action = 7 'acOLEActivate
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top