Have a need to have seven initial worksheets in a workbook, but how do you add another 4 to the three as default? Both the 'add on opening' workbook and the 'add on fly' to an open workbook methods are required please. Code so far...
procedure ExcelOpen(Sender: TObject; Excelname:String);
begin
// If the workbook exists, open it, else create an instance of it.
OleApplication := CreateOleObject('Excel.Application');
OleApplication.visible :=false;
if fileexists(dataq.outdir+'\'+Excelname) then
begin
OleWorkBook:=OleApplication.WorkBooks.open(dataq.outdir+'\'+Excelname);
end else begin
OleWorkBook:=OleApplication.WorkBooks.Add;
// what is the code that should generate the total 7 worksheets?
end;
end;
Hope this helps,
Russell
procedure ExcelOpen(Sender: TObject; Excelname:String);
var OleApplication: OleVariant;
OleWorkBook: Olevariant;
dwIndex: Integer;
begin
// If the workbook exists, open it, else create an instance of it.
OleApplication:=CreateOleO
OleApplication.Visible:=Fa
if fileexists(dataq.outdir+'\
OleWorkBook:=OleApplicatio
else
OleWorkBook:=OleApplicatio
// what is the code that should generate the total 7 worksheets?
for dwIndex:=OleWorkBook.WorkS
begin
OleWorkBook.Worksheets.Add
end;
end;