Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Location
    Stevenage, Bedfordshire, England
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change the Number of Copies to Print (Word 2000/ VB)

    Hi,
    I've got a really simple problem, that l just can't seem to work out (something to do with it being 4pm on a Friday l'm sure).
    I'm in VB6, and I want to display a Word print dialog, and change the number of copies to print. This number comes from the number of patients in a database.
    I've seen plenty of references to a 'numcopies' property, but l haven't seen a complete example, and l can't find it listed when l'm in VB.
    I've got as far as:
    With Application.Dialogs(wdDialogFilePrint)
    .Display
    End With
    which displays it fine, but nothing more.

    If l use 'Application.PrintOut Copies:=iRecCount', that works fine, but l don't want to actually print, just set things up. Is there a parameter for 'PrintOut' that would do this?

    This is driving me slightly potty, this has got to be an easy thing to do??!

    Thanks,
    Clare.

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Change the Number of Copies to Print (Word 2000/ VB)

    Public Sub test()
    With Dialogs(wdDialogFilePrint)
    .NumCopies = 4
    .Show
    End With
    End Sub

    You can find a list of valid arguments for built in dialog boxes at http://msdn.microsoft.com/library/default....ogArguments.asp

    If you want to change the number of copies after you have displayed the dialog box then you should use

    Public Sub test()
    With Dialogs(wdDialogFilePrint)
    If .Display = -1 Then
    .NumCopies = 4
    .Execute
    End If
    End With
    End Sub

    StuartR

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Change the Number of Copies to Print (Word 2000/ VB)

    Hopefully, Stuart gave you what you needed, but since you askd for a VB6 example, see below. I was unclear why you didn't want to print, so it may not be exactly what you want. You can find all of the dialog arguments in the Word VBA help file, "Built-in Word dialog boxes." Are you aware that a built-in dialog has a Show method which displays the dialog and does the operation? It also has the Display and Execute methods to only display and/or execute the current dialog. HTH --Sam
    <pre>Option Explicit

    Private Sub Command1_Click()
    ' Must use Project | References menu to
    ' set a reference to Microsoft word
    Dim wdApp As New Word.Application
    Dim wdDoc As Word.Document
    Dim lngCopies As Long
    Set wdDoc = wdApp.Documents.Add(Visible:=False)
    wdApp.Visible = True
    With wdApp.Dialogs(wdDialogFilePrint)
    .NumCopies = 5
    .Display
    lngCopies = .NumCopies
    End With
    wdDoc.Close SaveChanges:=False
    wdApp.Quit
    Set wdDoc = Nothing
    Set wdApp = Nothing
    MsgBox "You requested " & lngCopies
    End Sub</pre>

    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    New Lounger
    Join Date
    Oct 2002
    Location
    Stevenage, Bedfordshire, England
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change the Number of Copies to Print (Word 2000/ VB)

    Hi,
    Thanks for those code samples. Although VB still doesn't list 'numcopies' as available, when l ran the code with it in, it didn't have a problem with it, and all ran fine.

    I didn't want to do an actual print as the user is entering a search criteria, with a letter produced for each match. This could potentially run into the hundreds, so best to just give the option for the user to print x number of letters, and leave it up to them how many they actually want to print off at a time.

  5. #5
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Change the Number of Copies to Print (Word 2000/ VB)

    <hr>VB still doesn't list 'numcopies' as available<hr>
    The parameters change for each dialog, so you have to look at the help file or the link that Stuart gave you to see what parameters you can use. The FilePrint Dialog, for example, has Background, AppendPrFile, Range, PrToFileName, From, To, Type, NumCopies, Pages, Order, PrintToFile, Collate, FileName, Printer, OutputPrinter, DuplexPrint, PrintZoomColumn, PrintZoomRow, PrintZoomPaperWidth, PrintZoomPaperHeight parameters. Glad that you've got it working. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  6. #6
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Change the Number of Copies to Print (Word 2000/ VB)

    The documentation is on the whole OK- but I have certainly found a few dialog boxes where the documentation is either incomplete or incorrect. Use it, but treat it with caution.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •