How can I print Office documents from .NET uniformly?

Using Microsoft interOp objects, I can programmatically print a Word or Excel document.

Is there an easier and more uniform way to programmatically print all types of documents (.txt, .doc, .xls, .pdf, etc.)?

+2
source share
1 answer

Microsoft, by default, uses DDE to print from office products. Go to Tools / Folder / File Types, then search for .XLS and click Advanced. You will see a list of actions, one of which is Print. Inside is the DDE command that Excel uses to print, then close the document, and one of these commands exists for each product in the Office suite. Unfortunately, DDE uses the SendMessage API, but there was a library that wraps these functions for you:

http://ndde.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=4828

It is no longer an update, but should still do what you need if you only need a general way to print documents.

Interop , PrintOut. Word, :

object nullobj = Missing.Value;
doc.PrintOut(ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); 

, interop, DDE , Office - Win32, 90- .

, , !

Cheers,  

+3

Source: https://habr.com/ru/post/1750413/


All Articles