Solved

I need to print Word documents from Delphi

Posted on 2013-01-03
4
1,092 Views
Last Modified: 2013-01-09
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
0
Comment
Question by:starhu
[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
4 Comments
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 38741348
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
0
 
LVL 19

Accepted Solution

by:
Thommy earned 500 total points
ID: 38741608
With ShellExecute you can even print different types of documents without using COM interfaces!!!

Try this...
Print Documents From Delphi - Print PDF, DOC, XLS, HTML, RTF, DOCX, TXT
0
 
LVL 27

Expert Comment

by:Sinisa Vuk
ID: 38742956
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).
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 38754550
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!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Six Sigma Control Plans
Progress
Suggested Courses
Course of the Month6 days, 7 hours left to enroll

634 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