Baloven Posted November 21, 2007 Share Posted November 21, 2007 Hello, How to copy a sheet in the working book from a file of a pattern in Excel? ex. CODE $objExcel = ObjCreate("Excel.Application") With $objExcel .Visible = 0 .WorkBooks.Open(@ScriptDir&'\Templates\Ticket_rus.xlt', Default, False) .ActiveWorkbook.Sheets(1).Select() EndWith $objTempExcel = ObjCreate("Excel.Application") With $objTempExcel .Visible = 0 .WorkBooks.Open(@ScriptDir&'\Templates\Ticket_rus.xlt', Default, False) .ActiveWorkbook.Sheets(1).Select() EndWith $loSheet1 = $objTempExcel.Workbook.Sheets(1) $loSheet2 = ObjCreate($objExcel.ActiveSheet.Sheets(1)) $loSheet1.Workbook.Copy($loSheet2) $objExcel = $objExcel.Workbook.Sheets(1) its d'nt work Link to comment Share on other sites More sharing options...
Baloven Posted November 21, 2007 Author Share Posted November 21, 2007 pls help..... Link to comment Share on other sites More sharing options...
weaponx Posted November 21, 2007 Share Posted November 21, 2007 You double-posted this topic, go delete the other one here http://www.autoitscript.com/forum/index.php?showtopic=57713 Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 21, 2007 Share Posted November 21, 2007 (edited) Hello,How to copy a sheet in the working book from a file of a pattern in Excel?ex.its d'nt work I think your problem is opening two instances of the same file. Try opening the workbook, adding a sheet, then copying the active cell range from the source sheet to the new one. P.S. Even better, there is an $oExcel.ActiveWorkbook.ActiveSheet.Copy method. Makes it all easy. Edited November 21, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Baloven Posted November 21, 2007 Author Share Posted November 21, 2007 I need copy if count change... For $r = 0 to _GUICtrlListViewGetItemCount($ListView) If $r > 0 Then ..... copy Shet is original File if more 1 $ListView count EndIf Next Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted November 21, 2007 Moderators Share Posted November 21, 2007 You double-posted this topic, go delete the other one here http://www.autoitscript.com/forum/index.php?showtopic=57713I merged the topics, thanks. Link to comment Share on other sites More sharing options...
Baloven Posted November 22, 2007 Author Share Posted November 22, 2007 (edited) All the same it is impossible to make.It is necessary for me to insert into the open book a copy of a leaf from a pattern (form) with preservation of formatting under condition of if quantity of lines in ListView more than oneCODE$objExcel = ObjCreate("Excel.Application")With $oExcel .Visible = 1 .WorkBooks.Open((@ScriptDir&'\Templates\Ticket_rus.xlt', Default, False) .ActiveWorkbook.Sheets(1).Select()EndWithFor $r = 0 to _GUICtrlListViewGetItemCount($ListView) $a_Item = _GUICtrlListViewGetItemTextArray ($ListView, $r) If $r <> 0 Then ;Addition of a leaf in the book from an initial pattern ;..... So does not work $oTempExcel = ObjCreate("Excel.Application") With $oTempExcel .Visible = 1 .WorkBooks.Open(@ScriptDir & '\Templates\Ticket_rus.xlt', Default, False) .ActiveWorkbook.Activate .ActiveWorkbook.Sheets("Sheet1").Copy EndWith $SheetName = 'Sheet' & $r + 1 $objExcel.ActiveWorkBook.WorkSheets.Add.Activate $objExcel.ActiveSheet.Name = $SheetName $objExcel.ActiveWorkBook.WorkSheets.Paste $$oTempExcel.Application.DisplayAlerts = True $$oTempExcel.Application.ScreenUpdating = True $oTempExcel.Quit ;..... EndIf ..... Filling of the form ....NextPS Script write on MS Excel 2003 Edited November 22, 2007 by Baloven Link to comment Share on other sites More sharing options...
Baloven Posted November 22, 2007 Author Share Posted November 22, 2007 Please the guru prompt as to make? Link to comment Share on other sites More sharing options...
Baloven Posted November 22, 2007 Author Share Posted November 22, 2007 (edited) I already simply do not know what to do... In the Help on VBA - CODEWorksheets ("Sheet1").Copy After: = Worksheets ("Sheet3") but if this record to write down in AI $oTempExcel.ActiveSheet.Sheets(1).Copy After: = $objExcel.ActiveWorkbook.sheets(2)oÝ÷ Û«yÇ¢½æ¦ËZê³)ík§v'í¡Ê)É«¢+ØÀÌØí½QµÁ᰹ѥÙM¡Ð¹M¡ÑÌ Ä¤¹ ½Áäthat we receive copy a leaf in the separate (third) book... HOW TO DO???: ( HELP..... Edited November 22, 2007 by Baloven 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