![]() |
|
#3
|
||||
|
||||
|
If this is only for that little macro it's probably not worth adding the reference to the project, use late binding instead:
Code:
Sub CheckFileExist()
Dim MyFSO As Object
Set MyFSO = CreateObject("Scripting.FileSystemObject")
If MyFSO.FileExists("C:\temp\text.txt") Then
MsgBox "The File Exists"
Else
MsgBox "The File Does Not Exist"
End If
End Sub
Code:
Sub CheckFileExist2()
If Dir("C:\temp\text.txt") = "" Then
MsgBox "The File Does Not Exist"
Else
MsgBox "The File Does Exist"
End If
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Excel runtime error 48; error in loading dll | mwittman5 | Excel Programming | 0 | 01-19-2017 05:18 PM |
| Embeding Excel Docs in Word - Receiving Memory Error Message if Excel is open | kdash | Word | 0 | 05-06-2015 09:38 AM |
| Excel error window: Excel has stopped working | MunganBrus | Excel | 1 | 01-13-2015 11:19 AM |
Automation error Unknown error" message once they open the Excel file
|
hlina | Excel | 1 | 10-08-2013 09:14 PM |
Open Word w Excel & fill Word textboxes w info from Excel fields runtime error 4248
|
Joe Patrick | Word VBA | 2 | 01-30-2012 07:23 AM |