stormlolz Posted February 13, 2017 Share Posted February 13, 2017 Hello, I search a module which can import data of a xls or csv file into an other xls file ex : i have data in a xls file named data.xls (my data located in tab Sheet1) i want to import all into an other xls file name suivi.xls (in tab Import), before delete all data of this tab anyone can help me please? Thank you for all sorry for my english Link to comment Share on other sites More sharing options...
Subz Posted February 13, 2017 Share Posted February 13, 2017 Have a look at the Excel UDF in Autoit Help Link to comment Share on other sites More sharing options...
water Posted February 13, 2017 Share Posted February 13, 2017 Function _Excel_RangeCopyPaste is what you are looking for. Check example 2 in the help file. stormlolz 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
stormlolz Posted February 14, 2017 Author Share Posted February 14, 2017 (edited) Hello, Thank you i will try it Edited February 14, 2017 by stormlolz Link to comment Share on other sites More sharing options...
stormlolz Posted February 14, 2017 Author Share Posted February 14, 2017 (edited) Ok thank you it's running can we delete line with conditions before the copy ? ex : delete lines where columm A:A = "0" thank you a part of my code expandcollapse popupCase $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() EndSwitch Wend endfunc Func Import() ; Crée un objet application et ouvre un classeur exemple Local $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 Local $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 Local $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 Local $oRange1 = $oWorkbook1.Worksheets("export_optimus_PIC_J2013_JRecol").Range("A:G") Local $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) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeCopy Example 2", "L'import est terminé avec succès.") sleep(500) Fin() EndFunc Edited February 14, 2017 by stormlolz Link to comment Share on other sites More sharing options...
water Posted February 14, 2017 Share Posted February 14, 2017 How to filter and delete rows can be found here: My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now