Alaska Software Inc. - Copy and Paste Sheet in Excel
Username: Password:
AuthorTopic: Copy and Paste Sheet in Excel
Javier JareoCopy and Paste Sheet in Excel
on Sat, 10 Dec 2011 20:29:51 +0100
Hello,
    How can I copy and paste an entire sheet in Excel?

    I want to copy (and paste) the sheet, not the total range of the sheet 
in another sheet.

    Thanks in advance,

Javier Jareno dminfor@terra.es
AUGE_ OHRRe: Copy and Paste Sheet in Excel
on Sat, 10 Dec 2011 21:04:44 +0100
hi,

>    How can I copy and paste an entire sheet in Excel?
>
>    I want to copy (and paste) the sheet, not the total range of the sheet 
> in another sheet.

start Excel with your Sheet
open Macro with ALT_F11
do "manual" what you want
stop Macro

Macro now contain Information what to do.
if you do not understand it post it here in Newsgroup

in general you have to set RANGE and SELECT it

greetings by OHR
Jimmy
Javier JareoRe: Copy and Paste Sheet in Excel
on Sat, 10 Dec 2011 21:31:43 +0100
Thanks,
But the macro returns a expression like this: "... Sheets("SheetName").Copy 
Before := Sheets(n) ..."
and I don't know how to implement this (Xbase++ returns error),  like I do 
whit (i.e.) :
oSheet(n):Move()
or
oSheet(n):Move(,xSheet)

(sorry for my poor english language, I'm from Spain).

Javier Jareo dminfor@terra.es

<AUGE_ OHR> escribi en el mensaje 
news:489d1f45$77bab371$133e30@news.alaska-software.com...
> hi,
>
>>    How can I copy and paste an entire sheet in Excel?
>>
>>    I want to copy (and paste) the sheet, not the total range of the sheet 
>> in another sheet.
>
> start Excel with your Sheet
> open Macro with ALT_F11
> do "manual" what you want
> stop Macro
>
> Macro now contain Information what to do.
> if you do not understand it post it here in Newsgroup
>
> in general you have to set RANGE and SELECT it
>
> greetings by OHR
> Jimmy
>
>
AUGE_ OHRRe: Copy and Paste Sheet in Excel
on Sat, 10 Dec 2011 22:53:59 +0100
hi,

> But the macro returns a expression like this: "... 
> Sheets("SheetName").Copy Before := Sheets(n) ..."

we need "exact" hole macro to help you.

other Idea :
   "read" Excel Sheet into Xbase++ Array,
    add/insert your "new" Items in Array
    and "write" back Array to Excel Sheet

to do this "quick" do not "read"  Cell by Cell.
first "mark" hole Sheet and "calculate" RANGE for a (same Size) Array

 Speed things up by creating an object containing the cells
         oSheet := oExcel:Worksheets(1):cells
 "select" hole Sheet
         oWorkBook:workSheets(1):usedRange:Select

after you have a (same Size) Array you can do this

 create Array
         FOR i := 1 TO numRows
            AADD(aExcel,ARRAY(numColumns))
         NEXT
 Number Columne -> Letter "ZZ"
         cEnde := ZAHL2CHR(numColumns)
 now "paste" hole RANGE to Array
         aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(numRows)) ):value

where aExcel Array now contain all Excel Cell .. just in 1 Second !

greetings by OHR
Jimmy
Javier JareoRe: Copy and Paste Sheet in Excel
on Sun, 11 Dec 2011 23:39:38 +0100
Hi,
Your solution is valid for me.
But the solution I was looking for is the EMail from Jose Antonio Diego 
Kerejeta in "public.xbase++.lang.spanish" :

   LOCAL cPath:= CurDrive() + ':\' + CurDir() + '\'
   LOCAL oExcel, oWorkBooks, oWorkBookOut, oWorkBookIn, oSheetOut, 
oSheetInBefore
   oExcel:= CreateObject( "Excel.Application" )
   oWorkBooks    := oExcel:Workbooks
   oWorkBookOut  := oWorkbooks:Open( cPath + 'Out.xls' )
   oWorkBookIn   := oWorkbooks:Open( cPath + 'In.xls'  )
   oSheetOut     := oWorkBookOut:Sheets( 2 )
   oSheetInBefore:= oWorkBookIn:Sheets( 1 )
   oSheetOut:callMethod( 'copy', oSheetInBefore )
   ...

thank you,

Javier Jareo Serrano dminfor@terra.es

<AUGE_ OHR> escribi en el mensaje 
news:53a5bfdd$5f008b86$133fd1@news.alaska-software.com...
> hi,
>
>> But the macro returns a expression like this: "... 
>> Sheets("SheetName").Copy Before := Sheets(n) ..."
>
> we need "exact" hole macro to help you.
>
> other Idea :
>   "read" Excel Sheet into Xbase++ Array,
>    add/insert your "new" Items in Array
>    and "write" back Array to Excel Sheet
>
> to do this "quick" do not "read"  Cell by Cell.
> first "mark" hole Sheet and "calculate" RANGE for a (same Size) Array
>
>  Speed things up by creating an object containing the cells
>         oSheet := oExcel:Worksheets(1):cells
>  "select" hole Sheet
>         oWorkBook:workSheets(1):usedRange:Select
>
> after you have a (same Size) Array you can do this
>
>  create Array
>         FOR i := 1 TO numRows
>            AADD(aExcel,ARRAY(numColumns))
>         NEXT
>  Number Columne -> Letter "ZZ"
>         cEnde := ZAHL2CHR(numColumns)
>  now "paste" hole RANGE to Array
>         aExcel := oSheet:range( "A1:"+cEnde+LTRIM(STR(numRows)) ):value
>
> where aExcel Array now contain all Excel Cell .. just in 1 Second !
>
> greetings by OHR
> Jimmy
>
>