Msg Box

dantb

Active Member
Joined
Mar 20, 2002
Messages
358
Hi all. What I am trying to do is put an Msg Box into this script. If the file is located and (aa1)=713 it works. When the file is found and (aa1) is not equal to 713 it works. But if the file (Upe202.exe) is missing completely, I receive a run time error File not found. Any help would be appreciated. Thanks Dan


Private Sub Workbook_Open()
Workbooks.Open Filename:="C:windowsUpe202.xls"
If Range("AA1") = "713" Then
ActiveWorkbook.Close
Else
On Error Resume Next
ActiveWorkbook.Close
Call MsgBox("Set Up Req", 16, "Error")
ActiveWorkbook.Close
ActiveWorkbook.Close
End If
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

parry

MrExcel MVP
Joined
Aug 20, 2002
Messages
3,355
Hi to see if a file exists use DIR.

Example

If dir(c:filename.xls)="" then
msgbox "file not found"
exit sub
end if
 

Forum statistics

Threads
1,144,127
Messages
5,722,634
Members
422,450
Latest member
Springbok

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top