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("word.application"
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 "Error= " + Err.Description
Resume Exit_PreviewOpenWordFile
End Function
On the line of "Set doc = wrdApp.Documents.Open(strFile)" i get this error: "Object variable or with block variable not set"
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...
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("word.application"
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 "Error= " + Err.Description
Resume Exit_PreviewOpenWordFile
End Function
On the line of "Set doc = wrdApp.Documents.Open(strFile)" i get this error: "Object variable or with block variable not set"
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...