I have a code where i am printing word document. In the sample document there is a section with picure that has modified margins by user.
When i execute the code I recieve following message:
The margin of section 1 are set outside of printable area.
After processing document, it starts spooling and throws this promt How do i turn the notification dialog box off?
my code so far:
Process printJob = new Process();
printJob.StartInfo.Verb = "PrintTo";
printJob.StartInfo.Arguments = printerName;
printJob.StartInfo.ErrorDialog = false;
printJob.StartInfo.CreateNoWindow = true;
printJob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printJob.StartInfo.FileName = path;
printJob.StartInfo.UseShellExecute = true;
printJob.StartInfo.Verb = "print";
printJob.Start();
Where variable path > is file name path
http://word.mvps.org/faqs/macrosvba/OutsidePrintableArea.htm
According to this, you'll need to turn off background printing, then turn off Application.DisplayAlerts.
EDIT
You're not going to be able to do this with Process
. The "print" verb uses /x /dde to tell Word to print:
/x Starts a new instance of Word from the operating shell (for example, to print in Word). This instance of Word responds to only one DDE request and ignores all other DDE requests and multi-instances. If you are starting a new instance of Word in the operating environment (for example, in Windows), it is recommended that you use the /w switch, which starts a fully functioning instance.
To suppress the message, you're going to need to do interop instead:
Print(string path)
method:Application wordApp = new Application();
wordApp.Visible = false;
//object missing = Type.Missing;
wordApp.Documents.Open(path); //for VS 2008 and earlier - just give missing for all the args
wordApp.DisplayAlerts = WdAlertLevel.wdAlertsNone;
wordApp.ActiveDocument.PrintOut(false); //as before - missing for remaining args, if using VS 2008 and earlier
wordApp.Quit(WdSaveOptions.wdDoNotSaveChanges); //ditto
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With