Solved

I need to print Word documents from Delphi

Posted on 2013-01-03
4
978 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
4 Comments
 
LVL 37

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 26

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Filename to be appended with DateTimeof Download 3 56
Multi-layered image in FireMonkey 9 34
T-SQL:  Sigh---Boy, this is fun.... 12 46
Twebbrowser add css to the header 3 25
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

778 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