CiaronJohn Posted January 14, 2020 Share Posted January 14, 2020 Hi, I would like to seek for your assistance regarding function "_Excel_SheetCopyMove", I read necessary files, other related topics in forum, and yet I cannot perform the function well. I expect that the selected sheet from Workbook1 should be moved to Workbook2, but nothing happens. Please see my code below, any assistance would be very much appreciated. Thanks. expandcollapse popupFunc _BE_jnknsSeparateSheet( ) ; Local Variables Local $sLogTextFile = @ScriptDir & "\..\Log.txt", _ $sTestSheetFile, _ $sDrive, _ $sDir, _ $sFileName, _ $sExtension Local $aFilePath ;~ $aTestDesign Local $fOldSheet, _ $fNewSheet Local $hTextFile Local $oExcel, _ $oBook, _ $oSheet, _ $oBookName ; Open log text file $hTextFile = FileOpen($sLogTextFile, $FO_READ) ; Open testsheet $sTestSheetFile = FileReadLine($hTextFile,2) $sTestSheetFile = StringTrimLeft($sTestSheetFile,20) Local $aTestDesign[ ] = [ $sTestSheetFile ] $oExcel = _Excel_Open() $oBook = _Excel_BookNew( $oExcel, 1 ) For $i = 0 To UBound ( $aTestDesign, 1 ) - 1 _PathSplit($aTestDesign[$i], $sDrive, $sDir, $sFileName, $sExtension) Next MsgBox(0, "", $sDrive & $sDir ) $oBookName = $sDrive & $sDir & "testFile.xlsx" _Excel_BookSaveAs( $oBook, $oBookName, $xlWorkbookDefault, True ) $sTestSheetFile = _Excel_BookOpen ( $oExcel, $sDrive & $sDir & $sFileName & $sExtension ) $oBookName = _Excel_BookOpen ( $oExcel, True ) _Excel_SheetCopyMove ( $sTestSheetFile, "1", $oBookName, False ) _Excel_BookClose ( $sTestSheetFile ) _Excel_BookClose ( $oBookName ) EndFunc Link to comment Share on other sites More sharing options...
CiaronJohn Posted January 14, 2020 Author Share Posted January 14, 2020 5 minutes ago, CiaronJohn said: _Excel_SheetCopyMove ( $sTestSheetFile, "1", $oBookName, False ) Sorry this should be _Excel_SheetCopyMove ( $sTestSheetFile, 1, $oBookName, False ). Nevertheless, output is still unsuccessful. Link to comment Share on other sites More sharing options...
CiaronJohn Posted January 14, 2020 Author Share Posted January 14, 2020 Disregard this, we found what caused the unsuccessful event. Thanks Link to comment Share on other sites More sharing options...
water Posted January 14, 2020 Share Posted January 14, 2020 Could you please describe the problem and - if not obvious - the solution? So if someone else in the future hits the same problem he can easily find your post and save some time with the provided solution. 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...
CiaronJohn Posted January 14, 2020 Author Share Posted January 14, 2020 The problem I encountered was the new excel instance I created and used to be the container of sheet to be moved is not an object which is required by the function _Excel_SheetCopyMove. I just changed my snippet from $oBookName = _Excel_BookOpen ( $oExcel, True ) to $oBookName = _Excel_BookOpen ( $oExcel, oBookName ) Thank you @water for your UDF btw. Link to comment Share on other sites More sharing options...
water Posted January 14, 2020 Share Posted January 14, 2020 CiaronJohn 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...
CiaronJohn Posted January 14, 2020 Author Share Posted January 14, 2020 @water in relation with excel, is there any way to rename the whole workbook using autoit? Link to comment Share on other sites More sharing options...
Nine Posted January 14, 2020 Share Posted January 14, 2020 4 hours ago, CiaronJohn said: rename the whole workbook What do you mean ? Change the file name ? Rename all the sheets ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
seadoggie01 Posted January 14, 2020 Share Posted January 14, 2020 11 hours ago, CiaronJohn said: rename the whole workbook _Excel_BookSaveAs CiaronJohn 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
CiaronJohn Posted January 14, 2020 Author Share Posted January 14, 2020 4 hours ago, seadoggie01 said: Excel_BookSaveAs Haven't thought of that I'm sorry. Thank you @water Link to comment Share on other sites More sharing options...
seadoggie01 Posted January 15, 2020 Share Posted January 15, 2020 3 hours ago, CiaronJohn said: I'm sorry No need to be sorry, we all miss things... Speaking of, have you seen my sanity? CiaronJohn 1 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types 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