AHK打开excel工作簿并修复



嗨,谁能帮我下面的代码,我有一个excel表格,我需要打开和修复,然后保存,我这样做,因为它往往打破了很多。任何帮助,非常感谢

; Open the Excel document
xlApp := ComObjCreate("Excel.Application")    ; create a (new) instance of Excel
xlApp.Visible := true                         ; make Excel visible
xlApp := ComObjActive("Excel.Application")    ; make Excel active 
xlApp := xlApp.Workbooks.Open("C:UsersPhillDesktopNew Microsoft Excel Worksheet.xlsx", CorruptLoad := XlCorruptLoad.xlRepairFile)
xlApp := ""   ; clear the variable
return 

有两个问题:

  1. AHK不支持COM
  2. 的命名参数
  3. AHK不知道XlCorruptLoad。xlRepairFile意味着

解决方案:

  1. 根据AHK文档,使用逗号将值发送到CorruptLoad的适当位置。根据微软文档,这是15个参数中的最后一个。
  2. XlCorruptLoad的值。xlRepairFile是1,所以这就是你要传递给那个参数的内容。

下面是完整的(未测试)代码:

; Open the Excel document
xlRepairFile:= 1
xlApp := ComObjCreate("Excel.Application")    ; create a (new) instance of Excel
xlApp.Visible := true                         ; make Excel visible
xlApp := ComObjActive("Excel.Application")    ; make Excel active 
xlApp := xlApp.Workbooks.Open("C:UsersPhillDesktopNew Microsoft Excel Worksheet.xlsx", , , , , , , , , , , , , , xlRepairFile)
xlApp := ""   ; clear the variable
return 

最新更新