#include #include #include #include #include #include #include #include #include #include #include #include #include ;~ $pass = InputBox("Password", "Entrez le mot de passe de sécrité" & @CRLF & @CRLF &"","","$") ;~ if $pass = "optimusERT" Then ;~ GUI1() Else ;~ fin() ;~ endif GUI1() Func GUI1() Global $Largeur = 320, $Hauteur = 100, $Titre = "ImportOPTIMUS", $titre1 = "A" GLOBAL $Ver = "1.0" $Form1 = GUICreate($Titre & $Ver, $Largeur, $Hauteur, -1, -1) GUISetState(@SW_SHOW) $ButtonEXPORT = GUICtrlCreateButton("select source", 20, 10, 150, 30) $ButtonSUIVI = GUICtrlCreateButton("select destination", 20, 50, 150, 30) GUICtrlSetState(-1, $GUI_DISABLE) $ButtonIMPORT = GUICtrlCreateButton("Import", 200, 30, 70, 30) GUICtrlSetState(-1, $GUI_DISABLE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Fin() Case $ButtonEXPORT GLOBAL $source = FileOpenDialog("", "C:\Users\", "(*.xls)", 1 + 4 ) GUICtrlSetState($ButtonEXPORT, $GUI_DISABLE) GUICtrlSetState($ButtonSUIVI, $GUI_ENABLE) ;msgbox(0, "", $source) Case $ButtonSUIVI GLOBAL $destination = FileOpenDialog("", "C:\Users\", "(*.xlsx)", 1 + 4 ) GUICtrlSetState($ButtonSUIVI, $GUI_DISABLE) GUICtrlSetState($ButtonImport, $GUI_ENABLE) ;msgbox(0, "", $destination) Case $ButtonImport Import() sleep(1000) DeleteCDP() sleep(1000) Fin() EndSwitch Wend endfunc Func Import() ; Crée un objet application et ouvre un classeur exemple GLOBAL $oAppl = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Ouvre le classeur de destination GLOBAL $oWorkbook2 = _Excel_BookOpen($oAppl, $destination, False) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel3.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oAppl) Exit EndIf ; Ouvre le classeur source GLOBAL $oWorkbook1 = _Excel_BookOpen($oAppl, $source, True) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example", "Error opening workbook '" & @ScriptDir & "\Extras\_Excel1.xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oAppl) Exit EndIf sleep(500) ; ************************************************** *************************** ;définition de la source de la copie GLOBAL $oRange1 = $oWorkbook1.Worksheets("export_optimus_PIC_J2013_JRecol").Range("A:G") GLOBAL $oRange2 = $oWorkbook1.Worksheets("export_optimus_PIC_J2013_JRecol").Range("I:GG") ;définition de la destination de la copie _Excel_RangeCopyPaste($oWorkbook2.Worksheets("Export OPTIMUS"), $oRange1, "A:G") _Excel_RangeCopyPaste($oWorkbook2.Worksheets("Export OPTIMUS"), $oRange2, "I:GG") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 2", "Error copying cells." & @CRLF & "@error = " & @error & ", @extended = " & @extended) sleep(500) EndFunc Func DeleteCDP() _Excel_FilterSet($oWorkbook2, "Export OPTIMUS", Default, 1, "=test2", $xlFilterValues) ;~ Offset the range so it doesn't include the first line and delete the filtered rows $oWorkbook2.Worksheets("Export OPTIMUS").Offset(1,0).Resize($oWorkbook2.Worksheets("Export OPTIMUS").UsedRange.Rows.Count - 1).Rows.Delete ;~ Remove the filter _Excel_FilterSet($oWorkbook2, "Export OPTIMUS", Default, 0) MsgBox(0, "", "@error = " & @error & ", @extended = " & @extended) EndFunc Func Fin() Exit EndFunc ;==>Fin