Solved

TWordApplication errors with Word 2010: Call rejected by callee

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now