Stalevar
Прекрасно всё работаетТак не работает.
Код:
#include <Excel.au3>
FileWrite(@ScriptDir & "\TestExcel.xls", "")
$oExcel = _Excel_Open()
$sWorkbook = @ScriptDir & "\TestExcel.xls"
; $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) ; <= было
$oWorkbook = _Excel_BookOpenEX($oExcel, $sWorkbook) ; <= стало
Func _Excel_BookOpenEX($oExcel, $sFilePath, $bReadOnly = Default, $bVisible = Default, $sPassword = Default, $sWritePassword = Default, $bUpdateLinks = Default)
; Error handler, automatic cleanup at end of function
Local $oError = ObjEvent("AutoIt.Error", "__Excel_COMErrFunc")
#forceref $oError
If Not IsObj($oExcel) Or ObjName($oExcel, 1) <> "_Application" Then Return SetError(1, @error, 0)
If Not FileExists($sFilePath) Then Return SetError(2, 0, 0)
If $bReadOnly = Default Then $bReadOnly = False
If $bVisible = Default Then $bVisible = True
Local $oWorkbook = $oExcel.Workbooks.Open($sFilePath, $bUpdateLinks, $bReadOnly, Default, $sPassword, $sWritePassword)
If @error Then Return SetError(3, @error, 0)
Local $oWindow = $oExcel.Windows($oWorkbook.Name) ; <== Modified
If IsObj($oWindow) Then $oWindow.Visible = $bVisible ; <== Modified
; If a read-write workbook was opened read-only then set @extended = 1
If $bReadOnly = False And $oWorkbook.Readonly = True Then Return SetError(0, 1, $oWorkbook)
Return $oWorkbook
EndFunc ;==>_Excel_BookOpen