Results 1 to 6 of 6

Thread: Printing Issue

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    10

    Printing Issue

    I am printing from an excel sheet that is "hidden behind the scenes" in a vb app (the end user never sees teh excel sheet-I just want to capture it's print capabilities). How can I let the user select the number of copies. I wasa thinking of an input box where they enter the number of copies but I need to relay that value to Excel or the printer. "Printer.Copies" didn't generate an error but didn't generate the correct result either. Thanks!
    Bobba Buoy
    "True wisdom only comes through pain"

  2. #2
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    "Printer.Copies" didn't generate an error but didn't generate the correct result either
    Can you show us how you did it. I may only guess that your Printer object isn't set to your system default so it won't be able to change any of its properties.
    Roy

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    10

    Printing Issues Reply

    I just used

    Printer.Copies = intNumCopies

    (which is the value returned by the InputBox).
    Bobba Buoy
    "True wisdom only comes through pain"

  4. #4
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Here is how to find and set Default Printer:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" _
    4.                 (ByVal lpAppName As String, ByVal lpKeyName As String, _
    5.                 ByVal lpDefault As String, ByVal lpReturnedString As String, _
    6.                 ByVal nSize As Long) As Long
    7.  
    8. Private Sub Command1_Click()
    9. '=====================================
    10. Dim prt As Printer, prtName As String
    11.  
    12.     prtName = GetDefaultPrinter
    13.     For Each prt In Printers
    14.         If prt.DeviceName = prtName Then
    15.             Set Printer = prt
    16.             Exit For
    17.         End If
    18.     Next
    19.     'Label1.Caption = "Default Printer: " & Printer.DeviceName
    20.     Debug.Print "Default Printer: " & Printer.DeviceName
    21.     'you may now proceed with your printing
    22.     'Printer.Copies = intNumCopies
    23.  
    24. End Sub
    25.  
    26. Public Function GetDefaultPrinter() As String
    27. '=============================================
    28. Dim def$, di&, Pos&
    29.  
    30.     def = String$(128, 0)
    31.     di = GetProfileString("WINDOWS", "DEVICE", "", def, 127)
    32.    
    33.     def = Left(def, di)
    34.     Pos = InStr(1, def, ",")
    35.     GetDefaultPrinter = Left(def, Pos - 1)
    36.  
    37. End Function
    Roy

  5. #5
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Although, Excel's Workbook object has a method PrintOut:
    [vbcode}
    wrbk.PrintOut , , 3, , Printer.DeviceName
    [/Highlight]

    Try it and may be it will hepl you.
    Roy

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    10

    Printing Issue Reply

    Just Awesome! Thanks!
    Bobba Buoy
    "True wisdom only comes through pain"

Posting Permissions

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



Click Here to Expand Forum to Full Width