0
好吧,我想通了下面:)重命名非有效表與文件夾名稱的一部分
編輯決賽
添碼與文件夾名稱改變工作表名稱:
Sub readFolder()
On Error Resume Next
Const sMainPath As String = "C:\ example" 'write directory here
Dim sFile As String, sPathSeek As String, sPathMatch As String
Dim i As Integer, sFolders As String, x As Integer, n As Integer
i = 0
x = 2 'start with sheet2, because sheet1 = panel for buttons
sPathSeek = sMainPath
n = ActiveWorkbook.Worksheets.Count
sFile = Dir(sPathSeek, vbDirectory)
Do While Len(sFile) > 0
If Left(sFile, 1) <> "." Then
sName = "sheet" & x
If x > n Then
Sheets.Add After:=Sheets(Worksheets.Count), Count:=1, Type:=xlWorksheet
ActiveSheet.Name = sName
Sheets(sName).Name = sFile
Else
Sheets(sName).Name = sFile
End If
x = x + 1
End If
sFile = Dir
Loop
End Sub
感謝大家給我的想法來解決這個:)
'如果(GETATTR(sFile)和vbDirectory)= vbDirectory Then' >>假bcause GETATTR(sFile)= FOLDERNAME和vbDirectory = 16 – Aldin
更新我的代碼 – Aldin