Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select the printer when printing doc

former_member254358
Participant
0 Likes
2,189

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.

1 ACCEPTED SOLUTION
Read only

Juwin
Active Contributor
0 Likes
1,256

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

7 REPLIES 7
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,256

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

Read only

0 Likes
1,256

This message was moderated.

Read only

0 Likes
1,256

Why ?

Read only

0 Likes
1,256

I'm not sure that 'squat' of another question comply with the rules of the forum?

Read only

Juwin
Active Contributor
0 Likes
1,257

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

Read only

0 Likes
1,256

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.

Read only

Juwin
Active Contributor
0 Likes
1,256

You may get the current property before setting a new one. And then once the print command issued, change it back.

Thanks