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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

when open wrddocument ->object variable or with block variable not set

Status
Not open for further replies.

robin0223

Programmer
Apr 29, 2003
6
NL
Hello,

I want my users to get a preview of a Word document(located in the file system, just linked from the database) before opening it.

There for I use this code:

Public Function PreviewOpenWordFile(strFile As String)
Dim doc As Word.Document
Dim wrdApp As Word.Application
On Error Resume Next
Set wrdApp = GetObject(, "word.application")
If Err.Number <> 0 Then
Set wrdApp = CreateObject(&quot;word.application&quot;)
End If

On Error GoTo Err_PreviewOpenWordFile
Set doc = wrdApp.Documents.Open(strFile)

ubtbPreviewWordDocument = PreviewReplaceDirtyCharacter(doc.Content)

doc.Close
Set doc = Nothing
Set wrdApp = Nothing

Exit_PreviewOpenWordFile:
Exit Function

Err_PreviewOpenWordFile:
MsgBox &quot;Error= &quot; + Err.Description
Resume Exit_PreviewOpenWordFile

End Function

On the line of &quot;Set doc = wrdApp.Documents.Open(strFile)&quot; i get this error: &quot;Object variable or with block variable not set&quot;

When I tried it on Win98 with Access 2000, it worked. Now I'm working on Windows XP with Access 2000 and it doesn't...

Does anybody have any clue what i'm doing wrong?

For the curious pple

- Function PreviewReplaceDirtyCharacter replaces al dirty characters inside the .doc. These are shown as squares and all.

- ubtbPreviewWordDocument is an unbound textbox...
 
Alright, same code other error...
I now get &quot;Error in loading DLL&quot;

Anybody a clue?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top