0

我有一个将 XLSX 转换为 XLS 的 Applescript。我可以从 Google 团队云端硬盘(通过虚拟云端硬盘)获取文件,将其转换并保存到我的桌面。当我尝试将其保存到 Google Team Drive 上的“Out”文件夹时,我收到错误消息。

我相信我的输出路径不正确。我尝试了不同的方法来到达路径,但没有运气。

工作代码保存到桌面:

    set {year:y, month:m, day:d, time:t} to (current date)
    set today to (m as number) & d & y
    set TSCfilein to "Volumes:GoogleDrive:Team Drives:Sales:Customer Service:Inventory Feeds:TSC:In:TSC_Master.xlsx"
    set TSCfileout to (path to desktop as text) & "TSC" & today & ".xls" as string

    tell application "Microsoft Excel"
        activate
        open file TSCfilein
        tell workbook 1
            tell sheet 1
            save active workbook in TSCfileout as Excel98to2004 file format


        end tell

        close without saving
        end tell
    end tell

将 set TSCfileout 更改为以下内容会导致错误:

    set TSCfileout to "Volumes:Google Drive:⁨Team Drives⁩:Sales:Customer Service⁩:Inventory Feeds:TSC:Out" & "TSC" & today & ".xls" as string

预期结果是保存文件 Google Team Drive 文件夹。

错误:

“Microsoft Excel 出现错误:工作簿 1 的工作表 1 的活动工作簿不理解“保存”消息。” 当我尝试指向输出文件位置时。

4

1 回答 1

0

有一个普遍的误解:HFS 路径总是以磁盘名称开头,但从不以Volumes.

不要将其与 POSIX 路径混淆。

  • 作为 POSIX 路径的启动卷“Macintosh HD”是/作为 HFS 路径Macintosh HD
  • 作为 POSIX 路径的外部卷“Google Drive”是/Volumes/Google Drive作为 HFS 路径Google Drive

并且后面有一个丢失的冒号Out

您到外部卷的路径是

set TSCfileout to "Google Drive:⁨Team Drives⁩:Sales:Customer Service⁩:Inventory Feeds:TSC:Out:" & "TSC" & today & ".xls"

尾随强制as string是多余的。根据规则,最左边的类型是连接的结果类型。

于 2019-05-17T19:15:13.880 回答