LucieLastic
Programmer
Right, I've progressed in to embedding my 'live' spreadsheet in a form. The problem I have is it doesn't appear to be a brand new instance of Excel as weird behaviour happens, like losing scroll bars from independant Excel app. I'm not using a TExcelApplication component so need to find the equivalent ConnectKind property in the OLEContainer component. How can I force a new instance to be created in the OLEContainer?
I have the following code:
procedure TForm1.btnLoadSheetClick(Sender: TObject);
var ExcelSheet : Variant;
i : integer;
OLEContainer : TOLEContainer;
begin
try
Application.processmessages;
OLEContainer := TOLEContainer.create(Panel);
OLEContainer.Parent := Panel;
OLEContainer.Align := alClient;
OLEContainer.CreateObjectFromFile('d:\temp\TEST.xls', False);
OLEContainer.DoVerb(ovShow);//ovPrimary
// OLEContainer.Run; //<--Doesn't work right.
ExcelSheet := OleContainer.OleObject.Application.ActiveSheet;
// OleContainer.OleObject. Application. ConnectKind := ckNewInstance;
for i := 1 to OleContainer.OleObject.Application.ToolBars.Count do
OleContainer.OleObject.Application.ToolBars.Item.Visible := False;
ExcelSheet.cells.item[2, 2].value := edValue.text;
OleContainer.OleObject.Application.Run('Sheet4.CommandButton1_Click');
except
on e:exception do
MessageDlg('HandleXLSheet - '+e.message, mterror, [mbok], 0);
end;
end;
Many thanks in advance.
Lou
I have the following code:
procedure TForm1.btnLoadSheetClick(Sender: TObject);
var ExcelSheet : Variant;
i : integer;
OLEContainer : TOLEContainer;
begin
try
Application.processmessages;
OLEContainer := TOLEContainer.create(Panel);
OLEContainer.Parent := Panel;
OLEContainer.Align := alClient;
OLEContainer.CreateObjectFromFile('d:\temp\TEST.xls', False);
OLEContainer.DoVerb(ovShow);//ovPrimary
// OLEContainer.Run; //<--Doesn't work right.
ExcelSheet := OleContainer.OleObject.Application.ActiveSheet;
// OleContainer.OleObject. Application. ConnectKind := ckNewInstance;
for i := 1 to OleContainer.OleObject.Application.ToolBars.Count do
OleContainer.OleObject.Application.ToolBars.Item.Visible := False;
ExcelSheet.cells.item[2, 2].value := edValue.text;
OleContainer.OleObject.Application.Run('Sheet4.CommandButton1_Click');
except
on e:exception do
MessageDlg('HandleXLSheet - '+e.message, mterror, [mbok], 0);
end;
end;
Many thanks in advance.
Lou