发布网友 发布时间:2022-04-23 14:12
共2个回答
热心网友 时间:2022-07-01 06:53
Sub 宏建立文件夹()
'此宏用于根据已经存在的工作表“A列为1~1000,B列为公司名称”,在此文件目录下创建相应的文件夹放在“文件目录”文件夹中
Dim X As Integer, ZM As String, MM As String, LJ As String, P As String, MX As String
ZM = "文件目录"
LJ = ThisWorkbook.Path '当前文档的路径
P = LJ & "\" & ZM
If Dir(P, vbDirectory) <> "" Then
MsgBox "文件夹存在,请删除"
Else
MsgBox "文件夹不存在!,系统将创建一个名为" & "的文件夹"
MkDir P
Shell "EXPLORER.EXE " & P '打开文件夹《文件目录》
For X = 4 To 1000
ZM = "文件目录"
MM = Cells(X, 2)
LJ = ThisWorkbook.Path
P = LJ & "\" & ZM
MX = P & "\" & MM
If Cells(X, 1) = "" Then GoSub 100
MkDir MX '创建明细文件夹
Next X
End If
热心网友 时间:2022-07-01 08:11
利用FSO
即可。