Solved

TWordApplication errors with Word 2010: Call rejected by callee

Posted on 2011-02-14
2
1,689 Views
Last Modified: 2012-05-11
I am coming across an intermittent error with Word 2010 automation. When copying a table from one instance of word to another, I get a 'call rejected by callee' error. The same code works perfectly on earlier versions of Word.

Has anyone else seen/overcome this problem, or got any ideas that might help me?

Below is a very simple example that triggers the problem. Create an empty Word template file as C:\emptytemplate.dot, and another with a single table in it as C:\templatewithtable.dot. Place two TWordApplications on a form and run the code below. I am getting the error consistently within 3 runs of the application.

This only happens in Office 2010 - the problem does not exist in earlier versions of Windows. I am using Delphi 2009 and the Word XP TWordApplication components on Windows 7.

Thanks,

Gary
procedure TForm1.FormCreate(Sender: TObject);
var
  fWDGOTOLAST: OLEVariant;
  fWDGOTOLINE: OLEVariant;
  vTemplatePath, vTablePath: OLEVariant;
  vNewTemplate: OLEVariant;
  vDocumentDefinition: OLEVariant;
  vDocVisible: OLEVariant;
  i : Integer;
begin
  fWDGOTOLINE := WDGOTOLINE;
  fWDGOTOLAST := WDGOTOLAST;
  vTemplatePath := 'C:\emptytemplate.dot';
  vTablePath := 'C:\templatewithtable.dot';
  vNewTemplate := False;
  vDocumentDefinition := wdNewBlankDocument;
  WordApplication1.Documents.Add(vTemplatePath,vNewTemplate,vDocumentDefinition,vDocVisible);
  WordApplication2.Documents.Add(vTablePath,vNewTemplate,vDocumentDefinition,vDocVisible);
  WordApplication1.Visible := True;
  WordApplication2.Visible := False;
  for i := 0 to 10 do
  begin
    WordApplication2.ActiveDocument.Select;
    WordApplication2.Selection.Tables.Item(1).Range.Copy;
    WordApplication1.Selection.Paste;
  end;
  WordApplication1.Disconnect;
  WordApplication2.Disconnect;
  WordApplication2.Quit;
end;

Open in new window

0
Comment
Question by:theskintman
2 Comments
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 34894354
0
 

Author Closing Comment

by:theskintman
ID: 34916853
Perfect - thanks for pointing me to such a simple solution.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question