Avatar of starhu
starhu

asked on 

I need to print Word documents from Delphi

Hello,

I have Delphi 2010 Professional and I need to print Word documents from Delphi.
I read a lot of advice about "TWordApplication" (I quoted one below) but I haven't got such a component.

Take a look at the TWordApplication component on the servers tab of the component palette

  WordApplication1.Connect;
  WordDocument1.PrintOut();  //here is where you decribe all your parameters example: copies
  WordApplication1.Disconnect;
  WordApplication1.Quit;

Can you help me?

Thank you very much
DelphiProgramming

Avatar of undefined
Last Comment
developmentguru
Avatar of Geert G
Geert G
Flag of Belgium image

you actually do have such a component if you also have word

you needn't explicitly install it,
you can use the com interface like here
http://delphi.about.com/cs/adptips2003/a/bltip0303_5.htm
ASKER CERTIFIED SOLUTION
Avatar of Thommy
Thommy
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

I suggest Thommys solution. If you make application for another user or to yourself office/word must me installed before. Even for second solution you must word installed to print real doc document correctly, this solution makes possible to print other extensions
(or doc) with default application (for doc can be LibreOffice).
I feel like I need to voice my recommendation to follow Thommy's advice too.

  The company I am currently working at has, in the past, used a lot of Word automation.  Unfortunately they are making use of word at the same time.  This means we get hundreds of errors per month due to the COM automation of Word.  When the user has a dialog open and you are trying to do the automation, that will cause an error, and that is just one simple way a problem can come up.  Here are a few of the error messages we get every month from EurekaLog:

The RPC server is unavailable.
Unable to run the specified macro.
Word was unable to read this document.  It may be corrupt.
The object invoked has disconnected from its clients.
The caller is dispatching an asynchronous call and cannot make an outgoing call on behalf of this call.
An outgoing call cannot be made since the application is dispatching an input-synchronous call.
The object invoked has disconnected from its clients.
Call was rejected by callee.
(Just to list a few)

  COM automation of Office programs is something that experienced developers know to stay away from.  It causes far more headaches than it solves.

  I have seen it done well in a situation where there would be no user on the machine at the same time, but even then it is slow.  Trying to print invoices, via word automation, the system was able to generate 6 per minute (notice that is not printing them, just generating them).  A good reporting system like Fast Reports can do hundreds, possibly over 1,000, in the same minute.  It can also export to ODF (Open Document Format) which can be opened by word, any of more than a dozen other formats, or printed directly.

  If you have any input into this, please... for your own sanity, stay away from word automation!
Delphi
Delphi

Delphi is the most powerful Object Pascal IDE and component library for cross-platform Native App Development with flexible Cloud services and broad IoT connectivity. It provides powerful VCL controls for Windows 10 and enables FMX development for Windows, Mac and Mobile. Delphi is your choice for ultrafast Enterprise Strong Development™. Look for increased memory for large projects, extended multi-monitor support, improved Object Inspector and much more. Delphi is 5x faster for development and deployment across multiple desktop, mobile, cloud and database platforms including 32-bit and 64-bit Windows 10.

60K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo