User define number of copies printed via macro

H

Hellautomobile

Hi,

I am working on a macro which alow user to fill in number of copies to be
printed via a formfield.

Sub text()
X = ActiveDocument.FormFields("Text1")
ActiveDocument.PrintOut Copies:=X
End Sub

Ideally, page 1 will always be printed while the number of copies for page 2
can be defined by user by filling in a formfield.

At the moment, when I activate the macro, the printer just keeps printing
.......

Please help......
 
G

Graham Mayor

To print out x copies of the document you need

Sub test()
Dim x As Integer
x = ActiveDocument.FormFields("Text1").Result
ActiveDocument.PrintOut Copies:=x
End Sub

To print out page 1 plus x copies of page 2 you need

Sub Test()
Dim x As Integer
With ActiveDocument
x = .FormFields("Text1").Result
.PrintOut Range:=wdPrintRangeOfPages, Pages:="1", Copies:=1
.PrintOut Range:=wdPrintRangeOfPages, Pages:="2", Copies:=x
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
H

Hellautomobile

thanks a bunch Graham !!!


Graham Mayor said:
To print out x copies of the document you need

Sub test()
Dim x As Integer
x = ActiveDocument.FormFields("Text1").Result
ActiveDocument.PrintOut Copies:=x
End Sub

To print out page 1 plus x copies of page 2 you need

Sub Test()
Dim x As Integer
With ActiveDocument
x = .FormFields("Text1").Result
.PrintOut Range:=wdPrintRangeOfPages, Pages:="1", Copies:=1
.PrintOut Range:=wdPrintRangeOfPages, Pages:="2", Copies:=x
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top