Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

I need to print Word documents from Delphi

Posted on 2013-01-03
4
Medium Priority
?
1,140 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project
Suggested Courses

660 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