我想通过使用VBA Excel 2011在Mac OS X上的文件夹中的文件循环。我尝试了下面的代码,但它不起作用。尽管Mac OS X上的文件夹中的文件循环 - VBA Excel 2011
Sub ListAllFilesInDir()
Dim strFile As String
Dim strPath1 As String
strPath1 = ActiveWorkbook.FullName
MsgBox strPath1
strFile = Dir(strPath1)
MsgBox strFile
strFile = Dir()
MsgBox strFile
strFile = Dir()
MsgBox strFile
End Sub
当程序到达第一个MsgBox strFile
时,我得到活动工作簿的名称。我在某处读到使用Dir
而没有参数会导致文件夹中的下一个文件。但是这对我不起作用。我得到第二MsgBox strFile
命令一个空的消息框和一个错误(运行时错误5:无效的过程调用或参数”第三MsgBox strFile
命令我有4个文件的文件夹中,我通过努力环
。另外,我该怎么做只列出“.xslx”文件
如果你还在寻找一个答案,请访问以下链接:http://stackoverflow.com/questions/10045474/dir-function -not-working-in-mac-excel-2011-vba –