Solved

TWordApplication errors with Word 2010: Call rejected by callee

Posted on 2011-02-14
2
1,723 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

632 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