0
使用以下代碼我打開並閱讀excel數據,但文件在UI中打開。如何使用applescript讀取背景中的excel數據
set iRowNo to "A"
set iCellCount to "2"
set SheetName to "Sheet1"
on ExcelFileReadingData(iRowNo, iCellCount, SheetName)
set xlsFilePath to (path to desktop as Unicode text) & "SofTestSmokeAutomationSuite:DataSheet.xlsx" as Unicode text
tell application "System Events"
tell application "Microsoft Excel"
tell worksheet SheetName
activate
open xlsFilePath
delay 2
set iCellValue to value of range ("" & iRowNo & "" & iCellCount) as text
end tell
end tell
tell application "System Events"
tell application process "Microsoft Excel"
click button 3 of window "DataSheet.xlsx"
end tell
end tell
return iCellValue
end tell
end ExcelFileReadingData
我想在後臺打開此文件以及數據應在後臺得到讀應該有與Excel任何UI界面每一件事應該在後臺發生。
Excel版本= 11, O.S MAC = 10.9
感謝您關注它。但第二次運行腳本時出現錯誤,錯誤如下。 – Girish 2014-10-07 07:09:44
錯誤「Microsoft Excel出現錯誤:AppleEvent處理程序失敗。」數字-10000 – Girish 2014-10-07 07:10:04
我測試了它,並且我沒有多次運行它的錯誤。它按預期工作。你必須弄清楚你的結局發生了什麼。 – regulus6633 2014-10-07 14:11:07