I have the following code snippet that opens up word document T163.doc from C:\MyTCN\
When the file exists it opens up.
When it doesn't exist it throws out an error message box with a load of info and a Debug button.
However, I'd just like it to pop up a message box saying "File Does Not Exist"
I've tried playing around but can't achieve this as I'm not overly confident with error handling.
Any help would be greatly appreciated.
When the file exists it opens up.
When it doesn't exist it throws out an error message box with a load of info and a Debug button.
However, I'd just like it to pop up a message box saying "File Does Not Exist"
I've tried playing around but can't achieve this as I'm not overly confident with error handling.
Any help would be greatly appreciated.
Code:
Private Sub TCN_Click()
'In order to use this code you must set a reference to the
'Word object library by doing this. In the VB Editor click
'Tools, References. Then search for Microsoft Word n.n Object Library
'where n.n will depend on your version of Word.
Dim wdApp As Word.Application, wdDoc As Word.Document
var_tcn_hyperlink = "C:\MyTCN\T163.doc"
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set wdApp = CreateObject("Word.Application")
End If
On Error GoTo 0
Set wdDoc = wdApp.Documents.Open(var_tcn_hyperlink)
wdApp.Visible = True
End Sub