Solved

TWordApplication errors with Word 2010: Call rejected by callee

Posted on 2011-02-14
2
1,677 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 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

16 Experts available now in Live!

Get 1:1 Help Now