#include #include #include #include #include Opt( "WinTitleMatchMode",3) Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell $exp_val = ("100,500,1000,2000,4000,6000,8000,9000") Local $Exl_dir = "C:\Users\Luxima\Documents\" ; Excel files directory Local $Exl_File = "Excel_Tmp.xlsx" Local $Exl_sheetname = "Exposure" ; sheet name of the exposure excel shee ; Check if excel file is already open Local $sWorkbook = $Exl_dir & $Exl_File Local $Exl_File_tmp = stringsplit($Exl_File,".") $exl_title = $Exl_File_tmp[1] & " - Excel" MsgBox($MB_SYSTEMMODAL, "Warning", "Excel file is open" & @CRLF & $exl_title) If WinExists("[TITLE:" & $Exl_File_tmp[1] & " - Excel; CLASS:XLMAIN]") Then If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;Local $oWorkbook=_Excel_BookAttach($exl_title,"Title") Local $oWorkbook=_Excel_BookAttach($sWorkbook) If @error = 1 Then Exit MsgBox(0, "Error code is: "&@error, "Could not Attach Excel Book returning: " & $oWorkbook) Else Local $oExcel = _Excel_Open() If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $oWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) EndIf ; Activate and select desired sheet in the file $oWorkbook.Sheets($Exl_sheetname).Activate $oWorkbook.Activesheet.Select If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_sheet_select", "Error selecting the sheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;Change the fps value in excel file _Excel_RangeWrite($oWorkbook,$oWorkbook.Activesheet, "100","B1") Sleep(2000) ; Split the exposure with comma, space sperated into array Local $exp_array = StringSplit($exp_val, ", ", 2) Local $arr_size = Ubound($exp_array)-1 ; Loop through the exposure range values for $n = 0 to $arr_size step 1 ;Change the exposure value _Excel_RangeWrite($oWorkbook,$oWorkbook.Activesheet, $exp_array[$n],"B2") Sleep(2000) Next ; Close Excel file and excel instance created by _Excel_BookOpen _Excel_BookClose($oWorkbook,False) if WinExists("Excel") Then WinClose("Excel") EndIf