Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OLEContainer - how to get a brand new instance

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top