views:

1258

answers:

3

Hi All

I am using the following code to print a word document from a C# app.

            ProcessStartInfo info = new ProcessStartInfo(myDocumentsPath);
            info.Verb = "Print";
            info.CreateNoWindow = true;
            info.WindowStyle = ProcessWindowStyle.Hidden;
            Process.Start(info);

This works fine Word opens and prints the document, and then closes itself down. The issue is that Word opens visibly, despite CreateNoWindow = true, and WindowsStyle =Hidden. I would have expected these two settings to mean that Word opened silently.

EDIT: Please don't suggest Word object model automation - I have many different document types that need to be printed (PDF etc) - it is just Word docs that are causing the issue at the moment.

Any thoughts?

TIA

Matt

+4  A: 

Word is free to ignore (and apparently does ignore) your request that it remain hidden.

See also Why is my hidden process still visible?

Ed Guiness
Yes, that is true. And that is why there is no way around COM automation if you want your app not being visible.
0xA3
That's a pain - was hoping to avoid interops. Oh well...:-)
Matt
A: 

from above code you can print PDF docs also

A: 

You can try using Aspose.Words for .NET to print Word documents without Microsoft Word altogether.

romeok