小编AG1*_*G10的帖子

Dir()函数在Mac Excel 2011 VBA中不起作用

您好我正在尝试列出Excel工作簿所在的子目录中的所有文件.由于某种原因,代码无法执行超出Dir函数.任何人都可以建议吗?谢谢!

Sub ListFiles()

    ActiveSheet.Name = "temp"

    Dim MyDir As String
    'Declare the variables
    Dim strPath As String
    Dim strFile As String
    Dim r As Long

    MyDir = ActiveWorkbook.Path 'current path where workbook is
    strPath = MyDir & ":Current:" 'files within "Current" folder subdir, I am using Mac Excel 2011

    'Insert the headers in Columns A, B, and C
    Cells(1, "A").Value = "FileName"
    Cells(1, "B").Value = "Size"
    Cells(1, "C").Value = "Date/Time"

    'Find the next available row
    r = Cells(Rows.Count, "A").End(xlUp).Row + …
Run Code Online (Sandbox Code Playgroud)

excel vba excel-vba excel-vba-mac

13
推荐指数
1
解决办法
3万
查看次数

标签 统计

excel ×1

excel-vba ×1

excel-vba-mac ×1

vba ×1