将 Excel 文件另存为新创建的文件夹
Posted
技术标签:
【中文标题】将 Excel 文件另存为新创建的文件夹【英文标题】:Save Excel File As to newly created folder 【发布时间】:2014-02-25 12:22:14 【问题描述】:我正在写一个 applescript 基本上要求'Job Number', 'Client Name' and 'Job Description'
然后创建一个新文件夹(带有一些子文件夹)到服务器上的位置,其名称是这三个问题的组合.然后它会打开一个 Excel 模板文件(工作表)并填写几个字段。
到目前为止一切顺利。
我搁浅的地方是将 Excel 文件保存到新创建的作业文件夹的子文件夹中,文件名为 jobNumber & "_jobsheet.xls"。
如果你看线...
save workbook as myWorkbook filename "MATRIX:11. Misc. Design Work:01. Live Jobs:" & folderName & jobNumber & "_jobsheet.xls"
...路径是创建新文件夹的位置,但我似乎无法将folderName
添加到路径中,否则它不会成为(相当长的)filename
的一部分。它将文件保存到'01。 Live Jobs',但不在刚刚创建的新作业文件夹中。
简而言之,我想要实现的是将 Excel 文件作为 jobNumber_jobsheet.xls 保存到文件夹“MATRIX:11.xls”中。杂项。设计工作:01。实时工作:文件夹名称'
我觉得我很接近了,但我开始绕圈子了,非常感谢任何帮助。
这是完整的脚本;
set jobNumber to text returned of (display dialog "Enter Job Number" default answer "")
set clientName to text returned of (display dialog "Enter Client name" default answer "")
set jobDescription to text returned of (display dialog "Enter Job Description" default answer "")
set folderName to jobNumber & "-" & clientName & "_" & jobDescription
set filePath to "MATRIX:11. Misc. Design Work:01. Live Jobs:"
tell application "Finder"
set newfo to make new folder at filePath with properties name:folderName
make new folder at newfo with properties name:"Images & Logos"
make new folder at newfo with properties name:"Job Sheet"
make new folder at newfo with properties name:"~Proofs"
make new folder at newfo with properties name:"To Print"
end tell
tell application "Microsoft Excel"
open file "ACCOUNTS:Misc Design Jobs:Templates:blank_jobsheet.xlt"
set jobNumberRange to range "F1" of worksheet 1 of active workbook
set value of jobNumberRange to jobNumber
set clientNameRange to range "B4:C4" of worksheet 1 of active workbook
set value of clientNameRange to clientName
set jobDescriptionRange to range "B6:C6" of worksheet 1 of active workbook
set value of jobDescriptionRange to jobDescription
set myWorkbook to active workbook
save workbook as myWorkbook filename "MATRIX:11. Misc. Design Work:01. Live Jobs:" & folderName & jobNumber & "_jobsheet.xls" with overwrite
end tell
【问题讨论】:
【参考方案1】:您只需在文件夹名称和文件名之间添加一个冒号:
...实时工作:" & folderName & ":" & jobNumber & "_jobsheet.xls"
【讨论】:
太棒了!我知道我很接近了!非常感谢。以上是关于将 Excel 文件另存为新创建的文件夹的主要内容,如果未能解决你的问题,请参考以下文章
如何将文件夹中的多个源工作簿中的数据复制到另一个工作簿,然后另存为新工作簿