首页 > 解决方案 > 使用 Excel 和 VBA 打开文件(在 Mac 上)

问题描述

在为我的客户完成宏之后,他告诉我他有一台 Mac。我试图调整 Mac 的代码,但我没有 Mac 来测试它。我有 Mac 的朋友试图帮助我,但他没有任何运气。

我需要在 Matters 文件夹中找到所有文件名并将它们放在 B 列中。我需要在 RCTI 文件夹中找到所有文件名并将它们放在 D 列中。

在此处输入图像描述 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

我希望这行代码可以解决问题,但事实并非如此。

strFile = Dir(strPath, MacID("XLSX"))

我的朋友运行宏并出现错误。他无法真正向我解释这个错误。

Matters = Range("B3").Text
strPath = Matters
strFile = Dir(strPath, MacID("XLSX"))
Row = 7
Do While strFile <> ""

    Range("B" & Row).Value = strFile
    Row = Row + 1
    strFile = Dir 'This moves the value of strFile to the next file.

Loop


Matters = Range("B3").Text
strPath = Matters
strFile = Dir(strPath, MacID("CSV"))
'strFile = Dir(strPath & "*.csv")
Do While strFile <> ""

    Range("B" & Row).Value = strFile
    Row = Row + 1
    strFile = Dir 'This moves the value of strFile to the next file.

Loop


RCTI = Range("B4").Text
strPath = RCTI
strFile = Dir(strPath, MacID("XLSX"))
Row = 7
Do While strFile <> ""

    Range("D" & Row).Value = strFile
    Row = Row + 1
    strFile = Dir 'This moves the value of strFile to the next file.

Loop


RCTI = Range("B4").Text
strPath = RCTI
strFile = Dir(strPath, MacID("CSV"))
Do While strFile <> ""

    Range("D" & Row).Value = strFile
    Row = Row + 1
    strFile = Dir 'This moves the value of strFile to the next file.

Loop

标签: excelvbamacos

解决方案


推荐阅读