Board index » delphi » excel process doesn't quit

excel process doesn't quit

Hi there!

I have the follwing procedures in the code for a dll:

// starting excel in the OLEContainer (ole is the Container)
if ole.visible = true then begin
  ole.destroyobject;
  ole.updateobject;
  ole.visible := false;
end;
ole.visible := true;
ole.destroyobject;
ole.visible := false;
ole.CreateObject( 'Excel.Sheet.8', false );
try
  ole.updateobject;
except
  result := false;
end;
if result then begin
  ole.visible := true;
  ole.doVerb( ovShow );
end;

// quitting excel in the OLEContainer
ole.destroyobject;
ole.close;
try
  ole.updateobject;
except
  ole.destroyobject;
  ole.close;
end;

Now my problems:
When I want to start the object in the container like above, excel pops up
an error message like "an outgoing call cannot be processed because the
application forwards an input-synchronized call". The second problem is,
that  when I call ole.createobjectfromfile after I started the server like
above, the excel process is still running when I quit the OLEContainer like
above. when I only start the server and then quit it, it terminates well.
What can I do? Please help!

Nils

 

Re:excel process doesn't quit


<<Nils Hammerich:
ole.destroyobject;
ole.close;
try
  ole.updateobject;
except
  ole.destroyobject;
  ole.close;
end;

Quote

It's very hard to get rid of Excel before it's ready. :)
This (posted by Marcus Br?ndle) might help:

var
  inplaceobj: IOleInPlaceObject;
...
  try
    inplaceobj := OleContainer.OleObjectInterface as
       IOleInPlaceObject;
    inplaceobj.InPlaceDeactivate;
    inplaceobj := nil;
    OleContainer.DestroyObject;
  except
  end;

--
Deborah Pate

Other Threads