+ Reply to Thread
Results 1 to 36 of 36

Command Button to Save Userform with dynamic name

  1. #1
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Command Button to Save Userform with dynamic name

    Hello,
    I have UserForm: frmQA911 with ComboBox19: (last name, first name) and Textbox10: =TODAY()

    I would like to save the form to a specific folder on the desktop ("Quality Assurance") as the following name: Smith, John_911_7/20/2014. This way, when the value in ComboBox19 and/or the date changes, a new file will be added to that folder.

    Can anyone help?

    If it can also be converted to a PDF, even better.

  2. #2
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Can anyone assist with this?

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

    Re: Command Button to Save Userform with dynamic name

    You can't save a userform.
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Can I convert a UserForm to some saveable file? PDF or otherwise?

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

    Re: Command Button to Save Userform with dynamic name

    You could transfer the data to a worksheet and then save the worksheet as a PDF.

    Or you could write the data to a text file.

  6. #6
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Please Login or Register  to view this content.
    That is the code for the UserForm. What could I add to this to either save it as a PDF or save it to a Word Document? It is an Evaluation, and I would like to be able to go back and review it down the road. There will literally be hundreds of these completed.

  7. #7
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Please Login or Register  to view this content.
    I snatched this from another site where the author was trying to accomplish the same thing. By this point, he was able to do nearly everything, but he did encounter an issue when clicking the button; it had to do with the ".ActiveDocument.SaveAs Filename:=SaveAsName" line. He apparently resolved it but never posted the final product, and the post is back from 2007. Anyone willing to help combine what I have posted with this code so that I could get a workable file?

  8. #8
    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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    I believe Norie is correct, one cannot save a Userform. However, one can save an image of a Userform to an Excel File. Is this of interest?
    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.

  9. #9
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Possibly, but I am concerned about the amount of data that would require. There will, literally, be hundreds of these forms submitted a year, and saving all of them as images could take up a lot of space.

  10. #10
    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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    Possibly, perhaps...you decide
    I am concerned about the amount of data that would require

  11. #11
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    At the moment and after all of the time I have dedicated to this project, I am willing to go any route to accomplish what i need.

    This is an employee database. The UserForms i want to save are evaluations. I would like to be able to access completed forms in the future (as PDF or whatever other method of saving them). We have hundreds of employees, and at minimum, 1 of these will be done/month for each employee.

    So, to answer your question....I'll take what i can get for now.

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

    Re: Command Button to Save Userform with dynamic name

    What was the problem with ActiveDocument.SaveAs in the Word code?

    Also, since you are already transferring the data to a worksheet could you not save that worksheet as a PDF?

    The code for that is pretty straighforward, here's an example.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Transferring it to a worksheet is a last resort. I'm not proficient, I'm not getting the desired appearance, and I spent a considerable amount of time designing the form. But, if it's the only way, so be it. I won't be able to try for a day or 2. Regardless, thanks for your help!!

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

    Re: Command Button to Save Userform with dynamic name

    Your code already transfers the data to a worksheet.

    Why is it a last resort?

    On a worksheet you can apply formatting to the data to get it to look as you want, you can't do that with a userform.

  15. #15
    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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    The Code in the attached demonstrates how to save a Copy of a UserForm to PDF. I'm not certain where I got this Code. I do know the vast majority of it was provided by Leith Ross.
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Please Login or Register  to view this content.
    Thanks for the help. I tried it in the above code, but I received a compile error in the keybd_event section. I attached this to a Command Button, so perhaps that is causing the issue. Can anyone assist?

  17. #17
    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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    If you will post your workbook with the UserForm and Code it'll be much easier to assist...

  18. #18
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    I would love to, but apparently the file is too large.

  19. #19
    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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    Try zipping it.

  20. #20
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Apparently, I was wrong.

    Attached is the workbook. The form I am specifically working on (for this issue among a plethora of others) is the QA911 form PRINT button.

    Be nice. I am a complete novice and am piecing things together as I go.
    Attached Files Attached Files

  21. #21
    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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    I'm ALWAYS nice...ask my Children...I MAY not ALWAYS be pleasant but I try to be.

    I'll look at it.

  22. #22
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    If I could get this to work perfectly, one click of a Command Button would save a copy of this Form into a specific folder (based upon the person that the QA is being completed) AND print the form so it could be signed and sent up the Chain of Command.

  23. #23
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Jaslake,
    Thanks...
    I may pick your brain for a few other things then....

  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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    The PDF will be saved to a File based on the value of Combobox19 of frmQA911?

  25. #25
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Yes, if possible. I sent you a PM
    Last edited by tapsmiled; 07-25-2014 at 08:09 PM.

  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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    Do you want a PRINT and a SAVE Button or should they be combined?

    You have a Multi-Page User Form...not sure how to deal with that...yet...

  27. #27
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    I realize that the multi-page will be an issue, but there was no way around it unfortunately. I expected to put some type of message box alerting the user to print both pages of the form, but as you can tell, I have yet to tackle that. I don't mind separate buttons. The issue I ran into was that I boxes to go blank when the form is submitted, so it was impossible to print after submission. I'll take any solution I can find

  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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    The attached File has embedded Code to both Print and Save to PDF the User Form frmQA911. I've yet to consider the Multi Page issue.
    Attached Files Attached Files

  29. #29
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    Jaslake,
    Thank you so much! When I try to print it though, I notice it is cutting off the right side of the form. It looks as if you made the form a bit narrower. Do I have to do that in order for the entire form to fit completely or is there a way to adjust the margins?

  30. #30
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    And not to look a gift horse in the mouth, but is there a way to do it so that the toolbar at the bottom is not showing?

  31. #31
    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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    Replace the Print Button Code with this
    Please Login or Register  to view this content.
    Replace the Save Button Code with this
    Please Login or Register  to view this content.
    What are you referring to here?
    the toolbar at the bottom is not showing

  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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    See if this Code suffices for the Multi Page issue:

    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.

  33. #33
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    I'll check. You are really awesome. Thanks!

  34. #34
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    For the Print code, I get a Sub or Function not defined error for the Keybd_event. That was the same issue I was having before.

  35. #35
    Forum Contributor
    Join Date
    11-13-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    464

    Re: Command Button to Save Userform with dynamic name

    For the both codes, I get a Sub or Function not defined error for the Keybd_event. That was the same issue I was having before.

  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: Command Button to Save Userform with dynamic name

    Hi tapsmiled

    There's some Code that you're missing.
    Please Login or Register  to view this content.
    In the attached there's a General Module named Print_Save; the above Code is in that Module.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] UserForm in Excel- command button to save record
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-15-2013, 11:50 AM
  2. [SOLVED] 'Save' or 'save as' Command Button VBA Excel
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-07-2013, 04:09 PM
  3. Command button to save
    By troysie in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-31-2011, 04:26 AM
  4. Userform Command Button to open new userform
    By JamesT1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2010, 12:02 PM
  5. Save Command Button Help!
    By EnGo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-27-2006, 04:55 PM

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