g0gcd Posted 22 hours ago Posted 22 hours ago (edited) #include <Excel.au3> Local $sResultTemplateFilename = @ScriptDir & "\Test.xls" ;Set up demo workbook Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oExcel, $sResultTemplateFilename, Default, True) _Excel_SheetAdd($oWorkbook, Default, 1, Default, "Template") $oWorkbook.Sheets("Template").Activate ;All above works fine ;Statement which doesn't work as expected _Excel_SheetCopyMove($oWorkBook, "Template", $oWorkBook, "Copy", Default, True) ;Expected : Test.xls has two sheets, Template and Copy ;Actual : Test.xls has Template sheet, Book1.xls has Template sheet Help, I've been banging my head against a brick wall for days. What am I doing wrong above? I'm trying to achieve a simple duplication of a Sheet within the same Book, named 'Copy'. What I'm getting is a new book with the sheet 'Template' in it. I've also tried _Excel_SheetCopyMove($oWorkBook, "Template", Default, "Copy", Default, True) which behaves the same way. Although not shown in the snippet, I check @error and it reports '0' in all cases. (As an aside, I've just abandoned the process using OpenOffice and LibreOffice, with OOo_Calc.au3, due to a bug in the chart drawing functionality in that product - several days wasted in that effort! 😉 ) Thanks John Edited 22 hours ago by g0gcd Missed a bit..
Solution Nine Posted 22 hours ago Solution Posted 22 hours ago Take a look at the example of _Excel_SheetCopyMove. You are naming the new sheet wrongly ("Copy"). Create new sheet then rename it. Local $oCopiedSheet = _Excel_SheetCopyMove($oWorkBook, "Template", Default, Default, Default, True) $oCopiedSheet.Name = "Copy" “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
g0gcd Posted 9 hours ago Author Posted 9 hours ago @Nine Thank you for pointing out that which should have been blindingly obvious. I'm guilty of not looking carefully enough and was so bogged down with OpenOffice (which does copy/paste and rename in one step) that I didn't see what was in front of me. Much appreciated and thanks for your time John G0GCD
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