+ Reply to Thread
Results 1 to 39 of 39

print userform and save to pdf

  1. #1
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    print userform and save to pdf

    hi
    i am looking for probably a macro that will either print a userform to pdf file and save, or print screen and and save so i can email them on ,have tried different threads (codes) but none really seem to work, after they have been saved in workbook or folder i will be emailing them on
    any pointers please
    cheers colin
    Last edited by cfinch100; 02-03-2013 at 04:07 PM.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: print userform and save to pdf

    Hi this is a piece of code that works

    if you have a commandbutton on the userform
    place this code in the userform module

    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi
    says vk_lmenu not defined any ideas
    cheers colin

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: print userform and save to pdf

    Sorry
    forgot this piece of code that you need to put at the top of a general module
    this declares the constants

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi
    thanks for that sean still got problems though now ambigous name detected vk_snapshot
    userform runs but click command button and this appears although states in module its there
    cheers colin

  6. #6
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi sean
    have uploaded program frmmfrsa has command button6 on it
    not sure if put code in right place if you have time to look ,i must be doing something wrong
    cheers colin
    Attached Files Attached Files

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: print userform and save to pdf

    Colin

    You have the declarations in both Module1 and Module5.
    If posting code please use code tags, see here.

  8. #8
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi
    thanks norie i knew it was me ,this sends to one note can not see in code where it says it will send can it be sent to floder for email or direct to outlook for emailing
    cheers colin

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: print userform and save to pdf

    Colin

    When I run the code it seems to send something to the printer, doesn't print anything thouhgh - printer's offline.

    Doesn't do anything with OneNote though I do have it installed, not running though.

    Do you have it running?

  10. #10
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: print userform and save to pdf

    I have cutepdf writer installed.

    This code usually opens up a save as screen to save the pdf.
    cutepdf writer is a free programme you can down load

  11. #11
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi norie
    have installed one note and have the userform on screen but says it has 4 pages,not sure how to se one note have not had anything to do with it and printer at home is not working at minute ,that is why i wanted to send as pdf ,have pro writer at work
    cheers colin

  12. #12
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi sean
    no save as screen pops up here as said seems to send to one note
    chhers colin

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: print userform and save to pdf

    Colin

    Do your really need to print the form?

    Couldn't you have a template worksheet set out/formatted as required and send the data from the form there?

    Then you can save/send/print this worksheet rather than the form?

  14. #14
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    norie
    yes that would work i think, if i knew how to do it that way , will have to look through some threads and see how its done
    cheers colin

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Colin

    You already have code for putting data from the form to a worksheet.

    All you need is code similar to that but probably with more specifics on where the data goes.

    For saving, emailing etc you'll find plenty of examples if you search.

  16. #16
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi norie
    yes got all that thanks just doing template now will let you know how it goes
    cheers colin

  17. #17
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi norie
    just a question is it best to have textboxes on template to populate data or just use the cells and lookup
    cheers colin

  18. #18
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print userform and save to pdf

    Hi Colin

    In a Project I developed I have a UserForm that I send to Print Preview. I've modified the Code for you so it prints to PDF. The Code is assigned to a Print Button on the UserForm.

    See if it works for you.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  19. #19
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Hard you tell without knowing how you want the template to look.

    One thing to consider is that it's probably easier working with cells.

  20. #20
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi
    similar to frmmfrsanew that ive just uploaded, have put quick template sheet invoice thats not finished that has uses cells
    cheers colin
    Attached Files Attached Files

  21. #21
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi
    program stops at frmsummary.hide variable not defined any ideas
    cheers colin

  22. #22
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print userform and save to pdf

    Hi Colin

    frmSummary is the Name of MY UserForm...what's the Name of YOUR UserForm?

  23. #23
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi jaslake
    it does not like frmsummary.hide , have removed this and now works or seems to do not know where its saved them to so can veiw them think just says this workbook
    cheers colin

  24. #24
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print userform and save to pdf

    Hi Colin

    The PDF is saved here
    Please Login or Register  to view this content.
    This Workbook Path is the Folder of the File that's running the Code...look in that Folder...whatever it is.

    Your sentences are terribly hard to decipher...please use punctuation...I'm an OLD guy...humor me.

  25. #25
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi jaslake
    ive found it comes out as text.pdf ,all i have to do now is save them with different no's into my folder, prob if then statement to increase no's many thanks
    colin

  26. #26
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print UserForm and save to pdf

    Hi Colin

    It comes out as Test.pdf because this line of Code said to name it that
    Please Login or Register  to view this content.
    You'll need to come up with a Naming/Numbering scheme that works for you. If you require help with that define what it is you're trying to do...one of us will look at it.

  27. #27
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print UserForm and save to pdf

    hi
    many thanks for all your help will mark solved because looks like what i need but will try nories suggestion aswell
    thanks again colin

  28. #28
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print UserForm and save to pdf

    You're welcome...glad I could help. Thanks for the Rep.

  29. #29
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi sean
    you gave me this code it sends to c \documents,why can it be modified to go elsewhere
    cheers colin

  30. #30
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print userform and save to pdf

    Hi Colin

    If you're referring to John...change the path here
    Please Login or Register  to view this content.

  31. #31
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print UserForm and save to pdf

    hi jaslake
    can you tell me why this code saves to documents as book1,book2 ect , try and add code to direct to c:\desktop and it loses the auto no at the end, eg saves one at book
    then asks to overwrite, where in the code below does it point to documents folder to save
    Please Login or Register  to view this content.
    cheers colin

  32. #32
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print UserForm and save to pdf

    Hi Colin

    Please explain exactly what it is you're trying to do...perhaps I can help.

    Also, post the entire procedure.

  33. #33
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Post Re: print UserForm and save to pdf

    hi
    ill try and explain
    run program ,click reports
    enter2 in ainscough ref,click search,msgbox so many instances appear,double click on one record in listbox ,click email contact,repeat
    this sends userform to my documents as book1 and book2,i would like them sent to c:\users\colin\desktop\new\ but still use book1,book2
    auomatically entered,this i can not do ,managed to get it rediected once but only book1 went there
    when entered second record it wanted to rewrite over the first one,
    there are 8 records in list box at the minute that need copying over to folder \new\,these will be deleted when i email them to 2 users,
    is there a way to select all 8 records and save as one book before emailing, the next batch of completed records may only contain 4 records or less,i have an email macro, i think that should do the emailing,
    if i have to do one record at a time and auto save as book1,book2,book3 ect ,i will combine these into one work book and attach the workbook to the email macro
    any pointers would be good thanks
    cheers colin
    ps the code is in frmmfrsanew
    Attached Files Attached Files

  34. #34
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print UserForm and save to pdf

    Hi Colin

    Make certain this Folder exists
    c:\users\colin\desktop\new\
    Then assign this code to your Email Button...let me know of issues.
    Please Login or Register  to view this content.

  35. #35
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi
    brilliant just what i needed only concern if hit email button twice by mistake 1004 error occurs otherwise great
    many thanks colin

  36. #36
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print userform and save to pdf

    Hi Colin

    In the States we call this the "yips"
    if hit email button twice by mistake
    I'll look at it.

  37. #37
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print userform and save to pdf

    Hi Colin

    Add the two lines of Code as indicated...seems to work for me.
    Please Login or Register  to view this content.

  38. #38
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: print userform and save to pdf

    hi
    have just changed screen updating to true the one abovethis line ,
    Please Login or Register  to view this content.
    ll
    crashed on that line, works a treat ,thats great many thanks ,will try do some more myself thanks for help
    cheers colin

  39. #39
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: print userform and save to pdf

    You're welcome...glad I could help. Thanks for the Rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1