Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Printing a Word Doc From Access and specify # of copies
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
URQUILLA  
View profile  
 More options Nov 7, 9:01 am
Newsgroups: microsoft.public.access
From: URQUILLA <URQUI...@discussions.microsoft.com>
Date: Fri, 6 Nov 2009 14:01:01 -0800
Local: Sat, Nov 7 2009 9:01 am
Subject: Printing a Word Doc From Access and specify # of copies
I guess I fixed my own problem :). I looked every posting but just i coudn't
find what I was looking for. I needed to specify a #of copies to print. So
this is how the code looks like it if you need it.
For expert programmers please critize my code if there is something leaking
Or you need to add. Thank you.

Private Sub Command587_Click()

    lblPath.Tag = strPath & "\FileName.doc"
    lblPath.Caption = "Printing " & "... " & lblPath.Tag
    lblPath.HyperlinkAddress = lblPath.Tag

    doPrintBacking lblPath.Tag

 End Sub

Public Function doPrintBacking(FileName As String)
On Error Resume Next

Dim strInput As Integer, noOfCopies As Integer

    strInput = InputBox("Enter 1=for RICHO, Enter 2=for MINOLTA, 3=CANON")

    If strInput > 0 Then
        noOfCopies = InputBox("Enter # of Copies")

     If noOfCopies > 0 Then
        Set mobjWOrdApp = CreateObject("Word.Application")
        mobjWOrdApp.Documents.Open conTEMPLATE_NAME

       With mobjWOrdApp
        .Visible = False

        If strInput = 1 Then
        .ActivePrinter = "\\PRNTRM\RICOH"
        Forms!fPrintBacking!lblStatus.Caption = "->  Printing on RICOH \\ ->
" & noOfCopies & " Copies..."
        ElseIf strInput = 2 Then
        .ActivePrinter = "\\PRNTRM\MINOLTA"
        Forms!fPrintBacking!lblStatus.Caption = "->  Printing on MINOLTA \\
-> " & noOfCopies & " Copies..."
        ElseIf strInput = 3 Then
        .ActivePrinter = "\\PRNTRM\Canon"
        Forms!fPrintBacking!lblStatus.Caption = "->  Printing on CANON \\ ->
" & noOfCopies & " Copies..."
        End If
        DoEvents

        .PrintOut Background:=False

        .Documents.Application.PrintOut FileName:=conTEMPLATE_NAME,
Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=noOfCopies

        .ActiveDocument.Close False
        .Quit

        End With
      End If
   End If

    Set mobjWOrdApp = Nothing

End Function


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Beetle  
View profile  
 More options Nov 8, 5:06 am
Newsgroups: microsoft.public.access
From: Beetle <Bee...@discussions.microsoft.com>
Date: Sat, 7 Nov 2009 10:06:02 -0800
Local: Sun, Nov 8 2009 5:06 am
Subject: RE: Printing a Word Doc From Access and specify # of copies
I would suggest that you don't hard write values
(like printer names) into your code. If you add
another printer, or replace one with a different model,
you have to go back and rewrite the code.

You would be better off using a small popup form
(i.e. frmPrintOptions) where the user would enter
the number of copies in a text box and choose the
printer name from a combo box. Printer names could
be stored in a small lookup table. You would open
the form in Dialog mode in your code, which would
halt the code until the user is done with the form.
The form would have a command button (i.e. cmdContinue)
which would set the forms visible property to false,
allowing your code to continue. The form would still be
open so you could retrieve values from it. You may also
need a hidden check box on the form to use as a flag
to determine if the user entered values or not. you would
manipulate the check box True or False setting in the
Click event of the command button.

Your code might then look like;

Public Function doPrintBacking(FileName As String)
On Error Resume Next

    Dim strPrinter As String
    Dim intCopies As Integer

    DoCmd.OpenForm frmPrintOptions,,,,,acDialog

    If Forms!frmPrintOptions!chkFlag = True Then

      strPrinter = Forms!frmPrintOptions!cboSelectPrinter
      intCopies = Forms!frmPrintOptions!txtCopies

      Set mobjWOrdApp = CreateObject("Word.Application")
      mobjWOrdApp.Documents.Open conTEMPLATE_NAME

       With mobjWOrdApp
          .Visible = False
          .ActivePrinter = "\\PRNTRM\" & strPrinter & """"

          Forms!fPrintBacking!lblStatus.Caption = "->  Printing on " _
          & strPrinter & " \\ -> " & intCopies & " Copies..."

          DoEvents

         .PrintOut Background:=False

        .Documents.Application.PrintOut FileName:=conTEMPLATE_NAME,
Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=intCopies

        .ActiveDocument.Close False
        .Quit

        End With

       Set mobjWOrdApp = Nothing
    End If

End Function

The code won't execute unless the chkFlag on the popup form
is True. If you add or change a printer in the future, you simply
put another printer name in the table. No need to go back and
modify your code.

just a (long winded) suggestion :-).

--
_________

Sean Bailey


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google