H harrisw Registered User. Local time Today, 20:13 Joined Mar 27, 2001 Messages 131 Oct 11, 2004 #1 Hi I need to check whether a file exists before continuing the code. Not sure haw to check if a file exists. Thanks in advance
Hi I need to check whether a file exists before continuing the code. Not sure haw to check if a file exists. Thanks in advance
R Rob.Mills Registered User. Local time Today, 15:13 Joined Aug 29, 2002 Messages 871 Oct 11, 2004 #2 You need to add a reference to Microsoft.ScriptingRuntime Then in your sub Dim fso as New FileSystemObject If fso.FileExists("Full Path") Then
You need to add a reference to Microsoft.ScriptingRuntime Then in your sub Dim fso as New FileSystemObject If fso.FileExists("Full Path") Then
ghudson Registered User. Local time Today, 15:13 Joined Jun 8, 2002 Messages 6,193 Oct 11, 2004 #3 If you prefer not to deal with references then use the Dir() function. Code: If Dir("X:\YourFile.txt", vbNormal) <> "" Then MsgBox "Files exists." Else MsgBox "Files does not exist." End If
If you prefer not to deal with references then use the Dir() function. Code: If Dir("X:\YourFile.txt", vbNormal) <> "" Then MsgBox "Files exists." Else MsgBox "Files does not exist." End If