View Full Version : Something wrong with my macro
lCopiesToPrint = InputBox( _
Prompt:="Number of copies?", _
Title:="copies", _
Default:="1")
For lCounter = 0 To lCopiesToPrint - 1
ActiveDocument.Variables("CopyNum") = _
lCopyNumFrom + lCounter
ActiveDocument.PrintOut Copies:=1
Next lCounter
End Sub
I am trying to make a macro for printing asking how many copies I need, but this one prints all copies as separated print jobs..I thought of printing all the copies as one job..
Tinbendr
04-21-2012, 09:53 AM
lCopiesToPrint = InputBox( _
Prompt:="Number of copies?", _
Title:="copies", _
Default:="1")
ActiveDocument.Variables("CopyNum") = _
lCopyNumFrom + lCopiesToPrint
ActiveDocument.PrintOut Copies:=lCopiesToPrint
End Sub
It doesn't work quite right.
When I click cancel it still prints the job..
So basically I would need it to stop if I press the cancel button.
Tinbendr
04-21-2012, 10:35 AM
Sorry, I though you only wanted to fix the printout problem.
Sub test()
Dim lCopiesToPrint As Variant
lCopiesToPrint = InputBox( _
Prompt:="Number of copies?", _
Title:="copies", _
Default:="1")
If lCopiesToPrint > 0 Then
ActiveDocument.Variables("CopyNum") = _
lCopyNumFrom + lCopiesToPrint
ActiveDocument.PrintOut Copies:=lCopiesToPrint
End If
End Sub
Sorry, I though you only wanted to fix the printout problem.
Sub test()
Dim lCopiesToPrint As Variant
lCopiesToPrint = InputBox( _
Prompt:="Number of copies?", _
Title:="copies", _
Default:="1")
If lCopiesToPrint > 0 Then
ActiveDocument.Variables("CopyNum") = _
lCopyNumFrom + lCopiesToPrint
ActiveDocument.PrintOut Copies:=lCopiesToPrint
End If
End Sub
It works now I just copied the line a little below
ActiveDocument.Variables("CopyNum") = _
lCopyNumFrom + lCopiesToPrint
If lCopiesToPrint > 0 Then
lol, still doesn't work..
I tried relocating If > 0 Then line, but it didn't help..
Tinbendr
04-21-2012, 02:13 PM
eck! Sorry, my bad.
If Val(lCopiesToPrint) > 0 Then and probably for good measure.
ActiveDocument.PrintOut Copies:=Val(lCopiesToPrint)
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.