列出当前目录下的表格文件,VBA程序。

Sub FindFileCuurentFold()
Dim MyPath, MyName, WbN As String
Dim G As Long
Dim Num As Long
Dim Box As String
Application.ScreenUpdating = False
MyPath = ActiveWorkbook.Path
MyName = Dir(MyPath & "\" & "*.xlsx")
AWbName = ActiveWorkbook.Name
Num = 0
Do While MyName <> ""
 If MyName <> AWbName Then
  Num = Num + 1
  Sheets(1).Cells(Num, 1) = MyName
 End If
 MyName = Dir
Loop
Application.ScreenUpdating = True
MsgBox "共找到了" & Num & "个工作薄下的全部工作表。"
End Sub

 

 

发表评论

邮箱地址不会被公开。 必填项已用*标注