Outlook Add-In and excel problem

Add-in Express™ Support Service
That's what is more important than anything else

Outlook Add-In and excel problem
 
Christian Scholz


Guest


Hi,

When I run it, I get an exception: "error: the add-in has fired an exception access violation on address "0521DE26" in module "test.dll". Read on Address "000000FC".

procedure TAddInModule.adxCommandBar1Controls0Click(Sender: TObject);
var
wb : _Workbook;
ws : _Worksheet;
begin
ExcelApp.Workbooks.Close(0); //exception
wb := ExcelApp.Workbooks.Add(EmptyParam, 0);
ws := wb.ActiveSheet As _Worksheet;
ws.Cells.Item[1,1] := 'test';
end;

Or is it not possible to use "ExcelApp" in a Outlook Add-In?
Posted 24 Oct, 2006 12:07:25 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Christian,

Of course it is not possible to use the ExcelApp property from Outlook add-in. You can use the OutlookApp property.

Posted 25 Oct, 2006 06:40:18 Top
Christian Scholz


Guest


Hi Dmitry,

Thanks for the reply.

I forgot it completely:
OutlookApp.CreateObject('Excel.Application') As ExcelApplication;
Posted 25 Oct, 2006 08:32:00 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Christian,

I would recommend using the code similar to code below to get access to the Excel object model from an Outlook add-in:


uses ComObj, Excel2000;

procedure TAddInModule.test;
var
  IExcel: ExcelApplication;
begin
  IExcel := CreateOLEObject('Excel.Application') as ExcelApplication;
  if Assigned(IExcel) then
    try
      // TODO
      //IExcel.DoSomething
    finally
      IExcel := nil;
    end;
end;


Posted 25 Oct, 2006 08:51:28 Top