Jump to content
Sign in to follow this  
Baloven

How to copy a sheet in the working book from a file of a pattern in Excel?

Recommended Posts

Baloven

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 :P

Share this post


Link to post
Share on other sites
Baloven

pls help.....

Share this post


Link to post
Share on other sites
PsaltyDS

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

P.S. Even better, there is an $oExcel.ActiveWorkbook.ActiveSheet.Copy method. Makes it all easy.

:)

Edited 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

Share this post


Link to post
Share on other sites
Baloven

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

Share this post


Link to post
Share on other sites
Baloven

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 one

CODE

$objExcel = ObjCreate("Excel.Application")

With $oExcel

.Visible = 1

.WorkBooks.Open((@ScriptDir&'\Templates\Ticket_rus.xlt', Default, False)

.ActiveWorkbook.Sheets(1).Select()

EndWith

For $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

....

Next

PS Script write on MS Excel 2003 Edited by Baloven

Share this post


Link to post
Share on other sites
Baloven

Please the guru prompt as to make?

Share this post


Link to post
Share on other sites
Baloven

I already simply do not know what to do...

In the Help on VBA -

CODE
Worksheets ("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 by Baloven

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×