2016 Jun 17 12:23 PM
Hi,
I would like whether it's possible to select the printer when printing word document.
At this moment I've something like this:
CREATE OBJECT gs_word 'WORD.APPLICATION'.
SET PROPERTY OF gs_word 'Visible' = '0' .
CALL METHOD OF gs_word 'Documents' = gs_documents.
CALL METHOD OF gs_documents 'Open' = gs_newdoc
EXPORTING #1 = 'C:\Temp\doc2015.docx' .
CALL METHOD OF gs_word 'ActiveDocument' = gs_actdoc .
CALL METHOD OF gs_actdoc 'PrintOut' .
CALL METHOD OF gs_word 'Quit' .
FREE: gs_word, gs_actdoc, gs_documents, gs_newdoc .
Can anybody help me'
Thanks a lot.
Regards.
2016 Jun 17 2:49 PM
You just need to set the ActivePrinter to make this work:
set property of gs_word 'ActivePrinter' = 'PrinterName'.
Add this line, before the PrintOut command.
Edit: If you want user to have the option to choose the printer, then you can give a popup with a dropdown of printer names. List of printer names can be retrieved using RSPO_LIST_FRONTEND_PRINTERS function module. Check RSPO_FRONTEND_PRINTERS_FOR_DEV for example. Once the user chooses the printer from the dropdown, pass that selected value to the ActivePrinter name.
Thanks,
Juwin
Message was edited by: Juwin Pallipat Thomas
2016 Jun 17 12:32 PM
You should try to record a macro with word, so you could identify 'oWord.WordBasic.FilePrintSetup'.
Hint: set the printer value and use the option DoNotSetAsSysDefault:=1 you guess why (don't use oWorld.ActivePrinter you wont have the option and would be required to sace curent printer and reset it after completion)
Regards,
Raymond
2016 Jun 17 1:18 PM
2016 Jun 17 1:23 PM
2016 Jun 17 2:34 PM
2016 Jun 17 2:49 PM
You just need to set the ActivePrinter to make this work:
set property of gs_word 'ActivePrinter' = 'PrinterName'.
Add this line, before the PrintOut command.
Edit: If you want user to have the option to choose the printer, then you can give a popup with a dropdown of printer names. List of printer names can be retrieved using RSPO_LIST_FRONTEND_PRINTERS function module. Check RSPO_FRONTEND_PRINTERS_FOR_DEV for example. Once the user chooses the printer from the dropdown, pass that selected value to the ActivePrinter name.
Thanks,
Juwin
Message was edited by: Juwin Pallipat Thomas
2016 Jun 20 12:44 PM
Thanks a lot,
It's correct: set property of gs_word 'ActivePrinter' = 'PrinterName'.
One question. Once I've changed the printer, is it possible to change the printer to the previous default printer?
Regards.
2016 Jun 20 1:31 PM
You may get the current property before setting a new one. And then once the print command issued, change it back.
Thanks