View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default open file validation

Try the below..


Sub Macro()

Dim strFile As String
Dim wb As Workbook

strFile = "c:\1.xls"
If Dir(strFile, vbNormal) = "" Then
MsgBox strFile & vbLf & "File not found": Exit Sub
End If
Set wb = Workbooks.Open(strFile)
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Alberto Ast" wrote:

how do I validate while trying to open a file with macros so it will not fail
if file does not exist?