Board index » delphi » Copy Current Excel sheet to a New Sheet

Copy Current Excel sheet to a New Sheet

Hello

I am not sure of the ole copy syntax to create a new sheet from the current
sheet in excel, keeping all formating etc.

ExcelWorkbook.Worksheets.Copy(,ExcelWorksheet)

Thanks
Steve

 

Re:Copy Current Excel sheet to a New Sheet


<<Steve Johnson:
I am not sure of the ole copy syntax to create a new sheet
from the current sheet in excel, keeping all formating etc.

Quote

Worksheets have Copy and Move methods. You pass in the
worksheet you want the new sheet to be before or after as
an argument:

var
  After1, After2: OleVariant;
  Sh: _Worksheet;
begin
  Sh := Excel.Worksheets['Sheet1'] as _Worksheet;
  After1 := Excel.Workbooks[1].Sheets[3];
  After2 := Excel.Workbooks[2].Sheets[1];
  Sh.Copy(EmptyParam, After1, lcid);
  Sh.Move(EmptyParam, After2, lcid);

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads