VBA 创建文件夹和判断文件夹是否存在!
Public Function 创建文件夹(ByVal 路径 As String, ByVal 文件夹名称 As String)
Dim folder As Object
'设置FSO对象
Set fso = CreateObject("Scripting.FileSystemObject")
'如果文件夹不存在就创建
On Error Resume Next
If Not (fso.Folderexists(路径 & 文件夹名称)) Then
Set folder = fso.Createfolder(路径 & 文件夹名称)
MsgBox "< " & 文件夹名称 & " >文件夹创建成功!", vbInformation, "VB小源码提醒您!"
Else
MsgBox "< " & 文件夹名称 & " >文件夹已经存在!", vbInformation, "VB小源码提醒您!"
End If
End Function
使用方法:
Sub a()
Call 创建文件夹("C:\Users\", "文件名称")
End Sub
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有