-
StackOverflow 文档
-
VBA 教程
-
Scripting.FileSystemObject 的
-
创建 FileSystemObject
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Sub FsoExample()
Dim fso As Object ' declare variable
Set fso = CreateObject("Scripting.FileSystemObject") ' Set it to be a File System Object
' now use it to check if a file exists
Dim myFilePath As String
myFilePath = "C:\mypath\to\myfile.txt"
If fso.FileExists(myFilePath) Then
' do something
Else
' file doesn't exist
MsgBox "File doesn't exist"
End If
End Sub