Call Rejected By Callee UNLESS...

Hey,

I have an OLE automation app which works fine on some computers and on
others gets the dreaded "Call Rejected By Callee". I've matched the OS
and Excel version of one of these computers up to one where the app
works but still get the error--unless!

Unless Excel is already running! So, I'm trying to figure out if
there's anything the way I'm activating the thing that's causing the
problem:

procedure TForm1.FormCreate(Sender: TObject);
var V: OleVariant;
begin
   XLC.CreateObjectFromFile(ExtractFileDir(ParamStr(0)) +
'\sample.xls', False);
   XLC.DoVerb(ovShow);
   XLApp.Connect;
   XLWB.ConnectTo(XLApp.ActiveWorkbook);
   XLWBSheetActivate(nil, V);
   lcid := GetUserDefaultLCID;
   ActivateOLE;
   end;

ActivateOLE turns off all the command bars and dynamically creates a
main menu for the form (thus eliminating the Excel menus), but I get
the "Call rejected" error before it gets that far, so I don't think the
problem is there.

   I'm thinking of adding cdoe to explicitly starting Excel (and maybe
shut it down right after) to get around the problem but would like
suggestions for "neater" solutions.

    ===Blake===

Sent via Deja.com http://www.deja.com/
Before you buy.