Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 24

Thread: Solved: Print Prompt For Form

  1. #1
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location

    Solved: Print Prompt For Form

    I thought this would be a easy search, but came up empty.
    I have a form with a print button that I would like to get the Print Prompt, so I can select what printer and how many copies.

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Emoncada i think its something like this!
    [VBA]Application.Dialogs(xlDialogPrint).Show [/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    That prints out the spreadsheet, but I want it for the UserForm.

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    The userform has a print for method like:
    UserForm1.PrintForm
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Yes but just prints the userform once I need it to prompt the user how many copies wanted.

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I'm gonna throw this out there Em....why would you want to print a form?
    Why not format a sheet for printing and input your data to a for print sheet.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    This may be a sledgehammer to crack a nut, based on this KB item
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    This is apacking slip and needs to print in that form for the package then data is seperated on worksheet. Originally had it on a worksheet, but was able to add combo drop downs and works perfectly now except for the little print issue.

  9. #9
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Em,
    Read through this before you decide...
    http://www.vbaexpress.com/forum/show...ght=print+form
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  10. #10
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    MdMack is there a way to have that work for a form.
    Lucas I saw that post, but would rather keep it in a form.
    Is there a way a can call a module that has the print prompt so it can print the form?

  11. #11
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    My printer is non-functioning at the moment, but I'll try it at work tomorrow.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  12. #12
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Ok Md Thanks. Will look forward to it.

  13. #13
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Any Luck with this one?

  14. #14
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Em, did you not take a look at the sample that Md supplied?, if you did you would have noticed this section:
    [VBA]
    Private Sub CommandButton1_Click()
    Dim i As Long
    If Printer = "" Or Printer = "Not Found" Then Exit Sub
    Application.ActivePrinter = Printer
    Do
    UserForm1.PrintForm
    i = i + 1
    Loop Until i > Me.TextBox1.Value
    Unload frmPrint
    End Sub
    [/VBA]this in effect loops through thye print form code until i is greater than the value typed in the TextBox!, take a look at the code he supplied trim everything you dont want about setting printers and hey presto sorted!!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  15. #15
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    So then can i have a Inputbox Prompt to equal the value of i ?

  16. #16
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    OK I am trying this
    [vba] Dim l As Long, res As String
    'If Printer = "" Or Printer = "Not Found" Then Exit Sub
    'Application.ActivePrinter = Printer
    res = InputBox("How many Copies?", "Printer")
    Do
    UserForm1.printform
    l = l + 1
    Loop Until l > res
    Unload frmprint
    End Sub
    [/vba]

  17. #17
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    but that's giving me a problem with "frmprint" it's saying it's not defined.

  18. #18
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    oh ok i just saw the file. I am going to retry it.

  19. #19
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Jeeeez! Bob i see what you mean now!

    Em you will have a problem with frmprint because if your not using the workbook that Md posted you wont have a UserForm called frmprint!!!!!
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  20. #20
    VBAX Expert
    Joined
    Apr 2007
    Location
    Orlando, FL
    Posts
    751
    Location
    Ok i tried it the right way and got Not Found on both optionbuttons. Do i need to put my printer info somewhere for it to pick it up?

Posting Permissions

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