Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
open file validation
how do I validate while trying to open a file with macros so it will not fail
if file does not exist? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
open file validation
thanks Jacob, I'll try it...
thanks for your support on several questions today. "Jacob Skaria" wrote: 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. | Setting up and Configuration of Excel | |||
In Excel - Use Windows Explorer instead of File Open to open file | Excel Discussion (Misc queries) | |||
Open a file do a macro ( made) and open next succesive file | Excel Programming | |||
Open File or Switch Between Windows if File is Open | Excel Programming | |||
Open File or Switch Between Windows if File is Open | Excel Programming |