Excel 如何让Autohotkey写入元数据,然后提取元数据以用于重命名文件
我正在使用Auto热键自动执行一个过程,在该过程中,我将old.xlsx重命名为\u%Timestring上的document\u archived\u,然后将current.xlsx重命名为old.xlsx,然后将最新的\u document.xlsx重命名为current.xlsx 那部分很简单,效果很好 我想在最新的_document.xlsx中添加一条元数据注释,上面写着“data_as_of_u%Timestring%”。稍后,我想将old.xlsx重命名为“document\u%metadata%.xlsx” 下面是简单的工作脚本:Excel 如何让Autohotkey写入元数据,然后提取元数据以用于重命名文件,excel,autohotkey,Excel,Autohotkey,我正在使用Auto热键自动执行一个过程,在该过程中,我将old.xlsx重命名为\u%Timestring上的document\u archived\u,然后将current.xlsx重命名为old.xlsx,然后将最新的\u document.xlsx重命名为current.xlsx 那部分很简单,效果很好 我想在最新的_document.xlsx中添加一条元数据注释,上面写着“data_as_of_u%Timestring%”。稍后,我想将old.xlsx重命名为“document\u%me
; Take newest report, rename it to current. Take Current Report and move it to Old
; Take oldest report and archive it.
; Archive old report
FormatTime, Timestring, , yyyyMMdd
FileMove, G:\TPO_Project_DB\Old Data\old.xlsx, G:\TPO_Project_DB\Old Data\Eng_const_rpt_data_as_of_%Timestring%.xlsx
; Rename and move "current.xlsx" to "old.xlsx"
FileMove, G:\TPO_Project_DB\Current Data\current.xlsx, G:\TPO_Project_DB\Old Data\old.xlsx
; Rename and move newest report to current
FileMove, C:\TPOReports\Combined_eng_const_*, G:\TPO_Project_DB\Current Data\current.xlsx
我能够找到很多关于读取元属性的信息,但是关于写入这些…,我没有找到太多。我没有找到完整的解决方案,也就是工作代码的示例,但是可能至少有两种方法可以做到这一点 首先,这里有一些阅读元属性的参考链接。如果链接失效,搜索“FGP-FileGetProperties”应该会得到类似的结果
f1::
sFilePath := A_Desktop . "\test.xls"
oExcel := ComObjCreate( "Excel.Application" )
oExcel.Workbooks.Open( sFilePath )
oExcel.ActiveWorkbook.BuiltinDocumentProperties( "Comments" ).Value := "Test text"
oExcel.ActiveWorkbook.Save
oExcel.Quit
Return
另一种方法是使用DSOFile.dll
,可以在这里找到,
我对此一无所知,也不知道如何使用它,但它是为操作Office产品的属性而设计的,可能比打开上面代码片段中显示的每个文件要快得多。此外,它可能也不会更改“Date modified”值