我試圖添加引用到我的項目,所以我可以得到這個錯誤解決,但我沒有成功。用戶類型未定義工作表VBA
任何人都可以告訴我應該添加哪些庫嗎?
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim ws As Worksheet
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ws = Worksheets.Add
'Get the folder object associated with the directory
Set objFolder = objFSO.GetFolder("C:\")
ws.Cells(1, 1).Value = "The files found in " & objFolder.Name & "are:"
'Loop through the Files collection
For Each objFile In objFolder.Files
ws.Cells(ws.UsedRange.Rows.Count + 1, 1).Value = objFile.Name
MyFile = objFile.Name
NewName = getNewFileName()
您正在使用後期綁定,因此您不需要添加引用(請參閱http://support.microsoft.com/kb/245115)。錯誤在哪裏? – CuberChase 2013-03-17 23:05:41