Solved

TWordApplication errors with Word 2010: Call rejected by callee

Posted on 2011-02-14
2
1,695 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

820 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