2

Im running a simple app in python that is supposed to print a set number of pages from a document im working on. The document is 8 pages long but using

doc = word.Documents.Open(abs_docx_path)
doc.PrintOut(Range=1,From=1, To=2)

or

doc.PrintOut(From=1, To=2)

it still print every single page in the document instead of only the first and second one. Im running the latest version of word available. Is there something im doing wrong?

1 Answer 1

0

You should use Range=wdPrintFromTo

import win32com.client

wdPrintFromTo = 3
word = win32com.client.Dispatch("Word.Application")
word.Visible = False
abs_docx_path = r"abs_docx_path\document.docx"
doc = word.Documents.Open(abs_docx_path)

doc.PrintOut(Range=wdPrintFromTo, From=1, To=2)

doc.Close(False)
word.Quit()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.