jerem488 Posted May 28, 2018 Share Posted May 28, 2018 (edited) Hi, I have 2 workbooks and I want copy some lines but I think I'm not using the function correctly My problem is that the lines between the two files don't copy each other! I have many line _Excel_RangeCopyPaste(), it's for my tests ! #include <Excel.au3> Func TransposeExcel() Local $oExcel = _Excel_Open(False, False, False, False, True) Local $oExcel_2 = _Excel_Open(False, False, False, False, True) Local $oWorkbook = _Excel_BookOpen($oExcel, @DesktopDir & "\Workbook1.xls") Local $oWorkbookExport = _Excel_BookOpen($oExcel_2, @DesktopDir & "\Workbook_2.xls") Local $sResultA1 = _Excel_RangeRead($oWorkbook, Default, "A1") If Not @error Then Local $nLine = 2 Local $n = 2 Do Local $sColumA = _Excel_RangeRead($oWorkbook, Default, "A" & $n) If $sColumA = "OC" Then _Excel_RangeCopyPaste($oWorkbook.Worksheets(1), '"' & $n & ":" & $n & '"') _Excel_RangeCopyPaste($oWorkbook, '"' & $n & ":" & $n & '"', $oWorkbookExport.Worksheets(1).Range.Rows($nLine), Default, $xlPasteFormats) _Excel_RangeCopyPaste($oWorkbookExport.Worksheets(1), Default, '"' & $nLine & ":" & $nLine & '"', Default, $xlPasteFormats) ;~ _Excel_RangeCopyPaste($oWorkbook, $n, $nLine);, Default, $xlPasteFormats) $nLine += 1 EndIf $n += 1 Until $sColumA = "" _Excel_BookClose($oWorkbookExport) _Excel_BookClose($oWorkbook) _Excel_Close($oExcel) _Excel_Close($oExcel_2) EndIf EndFunc Edited May 28, 2018 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
water Posted May 28, 2018 Share Posted May 28, 2018 Example 2 in the help file for _Excel_RangeCopyPaste shows how to copy cells from one workbook to another one. BTW: You can delete $oExcel_2 (and fully replace it with $oExcel) as there is only a single reference to the Excel application needed. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jerem488 Posted May 28, 2018 Author Share Posted May 28, 2018 I tested the exemple 2, but in the exemple he don't copy a row Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
water Posted May 28, 2018 Share Posted May 28, 2018 I just ran example 2 and it worked fine. Can you please post the modification you made to copy an entire row? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jerem488 Posted May 29, 2018 Author Share Posted May 29, 2018 (edited) _Excel_RangeCopyPaste($oWorkbook.Worksheets(1), $oWorkbook.Worksheets(1).Range.Rows($n), $oWorkbookExport.Worksheets(1).Range.Rows($nLine), False, $xlPasteValuesAndNumberFormats) Edited May 29, 2018 by jerem488 Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
water Posted May 29, 2018 Share Posted May 29, 2018 You have to specify on which range you intend to work. Example: #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookNew($oExcel) _Excel_RangeWrite($oWorkbook, 1, "Test", "A1:G1") _Excel_RangeCopypaste($oWorkbook.Sheets(1), $oWorkbook.Sheets(1).Range("A1").entirerow, $oWorkbook.Sheets(1).Range("A2")) jerem488 1 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
jerem488 Posted May 29, 2018 Author Share Posted May 29, 2018 23 minutes ago, water said: You have to specify on which range you intend to work. Example: #include <Excel.au3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookNew($oExcel) _Excel_RangeWrite($oWorkbook, 1, "Test", "A1:G1") _Excel_RangeCopypaste($oWorkbook.Sheets(1), $oWorkbook.Sheets(1).Range("A1").entirerow, $oWorkbook.Sheets(1).Range("A2")) You are genious ! Thanks a lot ! Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
water Posted May 29, 2018 Share Posted May 29, 2018 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - 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