From: Naushad on
Hi All,

I have written a VBA code to open a word file in iexplore by the shell
command. If the file is not found a message is displayed and the
internet explorer is opened.

I want to display the custom message and don't want to open the
iexplore. My code are as follows

Private Sub cmdReport_Click()
On Error GoTo Err_cmdReport_Click

Dim VarPath As String
Dim VarReport As String
Dim varRepDate As Variant
Dim VarCon As String

VarPath = "C:\Documents and Settings\nhaider\Desktop\"
varRepDate = Format$(Me.ReportDate, "dd\-mm\-yy")
VarReport = varRepDate & "@" & Me.Project__ & ".doc"
VarCon = VarPath & VarReport

Shell "C:\Program Files\Internet Explorer\iexplore.exe " &
VarCon, vbMaximizedFocus


Exit Sub

MsgBox Err.Description
Resume Exit_cmdReport_Click

End Sub

Please help me to solve this problem.

Thanks in advance

From: Benny Andersen on
if len(dir(VarCon)) then
shell ....
msgbox ....

From: Naushad on
On Jan 31, 12:50 pm, Benny Andersen <a.mail.u...(a)> wrote:
> if len(dir(VarCon)) then
>    shell ....
> else
>    msgbox ....
> endif

Thank you very much. It is working properly.