Personalized Community is here!
Quickly customize your community to find the content you seek.
Have questions on moving to the cloud? Visit the Dynamics 365 Migration Community today! Microsoft’s extensive network of Dynamics AX and Dynamics CRM experts can help.
2021 Release Wave 2Discover the latest updates and new features releasing from October 2021 through March 2022.
2021 release wave 2 plan
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Community | FastTrack Program | Finance and Operations TechTalks | Customer Engagement TechTalks | Upcoming TechTalks | All TechTalks
I am trying to print a word document, and i found this code (https://blogs.msdn.microsoft.com/czdaxsup/2009/09/08/howto-print-word-document-from-x/) which works fine. But i also need to specify a specific printer, it is using the default printer. Can anybody help?
I read something about using the method ActivePrinter to set the printer, but it does'nt seem to work. I get the error Method not exist.
I am using Word 2016.
str document = "C:\\test.doc";
str printerName = "\\\\H\\MyPrinter";
// Create instance of Word application
wordApplication = new COM("Word.Application");
// Get documents property
wordDocuments = wordApplication.Documents();
// Open document wordDoc = wordDocuments.Open(document);
// Activate the document - this is necessary to print it
// Print the document
// Close document
// Close Word application
You can either change Application's ActivePrinter property or - if you don't want to change the default printer - call WordBasic.FilePrintSetup().
When i try to use active printer i get this error message
And when i try to use FilePrintSetup i get this message
My code is
// Or i tried this
wordDoc = wordDocuments.Open(_filename);
In the first case, you'll have to find out what kind of "printer error" it is. First of all, make sure that the printer name is correct and the printer is available.
In the latter case, you're trying to call the method on a wrong object (Application instead of WordBasic).
Thanks Martin. It worked, the name were missing the prefix for print server.
Business Applications communities