General discussion
April 19, 2001 at 11:13 AM
dennisbv

Handle an Error in Access with Word

by dennisbv . Updated 25 years, 3 months ago

Thanks to another member I got this far. I am getting the file name of a document from a database, stringing it together and opening it in Word. “Works great” But If the document does not exist I get an Error. What I am trying to do is if the file does not exist I want to display a message box telling the user to notify me. Now I intercept the error so the program does not stop, but Word opens still opens(with a blank screen. I want only the message box My code follows
Public Sub OpenWordDoc(asFileName As String)
Dim WordApp As Object

‘– Create instance of Word
Set WordApp = CreateObject(“Word.Application”)
WordApp.Visible = True

‘–open the file
On Error GoTo MissingGram_Err
WordApp.Documents.Open FileName:=”\\mee_pdc\Hyster gram\grams\” & asFileName & “.doc”

Set WordApp = Nothing

MissingGram_Err:
‘If IsNull(FileName) Then
‘MsgBox “file Not found, inform the Administrator”

‘End If

End Sub

Dennis

This discussion is locked

All Comments