chuongna37
Yêu THVBA
Mã:
sub test()
if "C:\dowload\text.xlsx" = True then
msgbox "file da co"
End if
end sub
sub test()
if "C:\dowload\text.xlsx" = True then
msgbox "file da co"
End if
end sub
cảm ơn tiền bối rất nhiều ạ !Sub Ktfile ()
Dim strFileName As String
Dim strFileExists As String
strFileName = "C:\Users\Nikola\Desktop\VBA articles\Test File Exists.xlsx"
strFileExists = Dir(strFileName)
If strFileExists = "" Then
MsgBox "file chua co”
Else
MsgBox “file da co “
End If
End Sub
cũng rất cảm ơn tiền bối ạ , nhưng máy mac ko chạy dc hàm này ạChia sẻ thêm
Dim IO As New FileSystemObject
MsgBox "File Exists is:=" & IO.FileExists("C:\dowload\text.xlsx")
Thử hàm UDF này xem saochào mọi người ý mình muốn diễn đạt là ví dụ trong đường dẫn trên đã có file text.xlsx rồi thì sẽ hiện thông báo file đã có ạ , mong được mọi người giúp đỡMã:sub test() if "C:\dowload\text.xlsx" = True then msgbox "file da co" End if end sub
Function FileExists(sFullPath As String) As Boolean
FileExists = CBool(Len(Dir$(sFullPath)) > 0)
End Function
cảm ơn tiền bối em đã làm được rồi ạThử hàm UDF này xem sao
Mã:Function FileExists(sFullPath As String) As Boolean FileExists = CBool(Len(Dir$(sFullPath)) > 0) End Function