• Macro to include number of copies option (MS Word

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Macro to include number of copies option (MS Word

    • This topic has 2 replies, 2 voices, and was last updated 20 years ago.
    Author
    Topic
    #419709

    I have recorded a macro to print page 1 then page 2 on a non-duplex printer. I would like to have a box appear when I click on the Print Page 1 or Page 2 buttons in which I can type the number of copies required. Can I be advised please on how to do this?

    This is the recorded macro:

    Sub Printpage1()

    ‘ Printpage1 Macro
    ‘ Macro recorded Thursday, 28 April 2005 by ME Walker

    Application.PrintOut FileName:=””, Range:=wdPrintRangeOfPages, Item:= _
    wdPrintDocumentContent, Copies:=1, Pages:=”1″, PageType:=wdPrintAllPages, _
    Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
    PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
    End Sub
    Sub Printpage2()

    ‘ Printpage2 Macro
    ‘ Macro recorded Thursday, 28 April 2005 by ME Walker

    Application.PrintOut FileName:=””, Range:=wdPrintRangeOfPages, Item:= _
    wdPrintDocumentContent, Copies:=1, Pages:=”2″, PageType:=wdPrintAllPages, _
    Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
    PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #948495

      Try this:

      Sub Printpage1()

      ‘ Printpage1 Macro
      ‘ Macro recorded Thursday, 28 April 2005 by ME Walker

      Dim lngCopies As Long
      lngCopies = Val(InputBox(“Enter the number of copies to be printed.”, , “1”))
      If lngCopies <= 0 Then
      Exit Sub
      End If
      Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
      wdPrintDocumentContent, Copies:=lngCopies, Pages:="1", PageType:=wdPrintAllPages, _
      Collate:=True, Background:=True, PrintToFile:=False, PrintZoomColumn:=0, _
      PrintZoomRow:=0, PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
      End Sub

      and similar for the other one.

      • #948526

        Thank you for your quick response. Once I grasped the difference between 1 (one) & l (ell) in lngCopies (the default font is TNR in my VB Editor) the improved macro worked AOK.

        Thank you again for your help – it is very much appreciated.

    Viewing 0 reply threads
    Reply To: Macro to include number of copies option (MS Word

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: