ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checking that file exist and if not display a message (https://www.excelbanter.com/excel-programming/353498-checking-file-exist-if-not-display-message.html)

[email protected]

Checking that file exist and if not display a message
 
Hi,

wrote some code for this:

Sub helpfile()

Dim Thehelpfile As Boolean

Thehelpfile = (Len(Dir("P:\Consignit
Templates\Consignit\Word\helpfile\How to use the word templates.doc"))
0)

If Thehelpfile = True Then
Application.Documents.Open Filename:="P:\Consignit
Templates\Consignit\Word\helpfile\How to use the word templates.doc"
Else
MsgBox "This functionality only works on the CAB office
Computers, You can download this help file from the intranet under
Tools/Templates"
Exit Sub
End If
End Sub

The problem is that if I pull the networkcable I get an error message
instead of the msgbox message I've written.

How to amend this so that if the networkdrive containing this file is
not available my message should appear?

Please help.

Thx!

/Jan


Tom Ogilvy

Checking that file exist and if not display a message
 
Sub helpfile()

Dim Thehelpfile As Boolean
Thehelpfile = False
On Error Resume Next
Thehelpfile = (Len(Dir("P:\Consignit
Templates\Consignit\Word\helpfile\How to use the word templates.doc"))
0)

On Error goto 0
If Thehelpfile = True Then
Application.Documents.Open Filename:="P:\Consignit
Templates\Consignit\Word\helpfile\How to use the word templates.doc"
Else
MsgBox "This functionality only works on the CAB office
Computers, You can download this help file from the intranet under
Tools/Templates"
Exit Sub
End If
End Sub

--
Regards,
Tom Ogilvy



wrote in message
ups.com...
Hi,

wrote some code for this:

Sub helpfile()

Dim Thehelpfile As Boolean

Thehelpfile = (Len(Dir("P:\Consignit
Templates\Consignit\Word\helpfile\How to use the word templates.doc"))
0)

If Thehelpfile = True Then
Application.Documents.Open Filename:="P:\Consignit
Templates\Consignit\Word\helpfile\How to use the word templates.doc"
Else
MsgBox "This functionality only works on the CAB office
Computers, You can download this help file from the intranet under
Tools/Templates"
Exit Sub
End If
End Sub

The problem is that if I pull the networkcable I get an error message
instead of the msgbox message I've written.

How to amend this so that if the networkdrive containing this file is
not available my message should appear?

Please help.

Thx!

/Jan





All times are GMT +1. The time now is 02:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com