+ Reply to Thread
Results 1 to 38 of 38

Generate All Forms and Memos From Macro

  1. #1
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Generate All Forms and Memos From Macro

    Hello,

    This has to do with the 'Training' worksheet. There is a column 'J' that will have a yes or no. Can a macro be created to generate all forms and a copy of the memo with all full names to be print previewed? If the ID has a yes then the employee name, employee number, and account needs to be filled out for each form to be printed.

    This may be a lot to ask but I hope it's possible. Also any thoughts on saving the form and memo would be appreciated. There will be other types of training required throughout the year.

    Thank you very much for your help in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    Did you want a new and separate form and memo created for each "Yes" in column J, in this case 14 new worksheets, one for each employee? If not, please explain how you want to use the form since it can only contain one employee name at a time.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Yes that is correct. The memos will all be the same but the forms will be different.

    Thank you

  4. #4
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    I don't really know how it works but can it fill out one employee info, print it, clear it, then fill out next employee?

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    Try:
    Please Login or Register  to view this content.
    I have disabled the line of code that prints the sheet. Do you not have to enter all the other data on the Training sheet before you print it out?
    Last edited by Mumps1; 01-18-2018 at 05:19 PM.

  6. #6
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Thank you for the code. I have to leave now but I am sorry this isn't what I wanted.

    Maybe it can't be done but I didn't want to create new sheets. There will be one type of training per sheet.

    I may have to give this more thought.

  7. #7
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    This revised macro will not create any new sheets. It will import the data for each employee one at a a time and print each one.
    Please Login or Register  to view this content.

  8. #8
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Thank you Mr. Mumps1 this is very close. The account number in G5 doesn't clear after printing and could there be commas and a space between the names in the memo area M5 please?
    Last edited by Billy Spivy; 01-19-2018 at 10:08 AM.

  9. #9
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    I attempted putting the commas. I put a comma and space instead of a space in the code. It puts a comma before the first name which shouldn't be so this isn't correct. Also if there is only one employee it will not need a comma.

    I figured out how to clear G5:

    .Range("G5").ClearContents
    Last edited by Billy Spivy; 01-19-2018 at 10:36 AM.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    Give this a try:
    Please Login or Register  to view this content.

  11. #11
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Thanks I tried it but error:

    Range("M5") = Left(join, Len(join) - 2)

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    It's working OK for me without an error. Try the attached file. The macro is in Module2.
    Attached Files Attached Files

  13. #13
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Sorry my bad. I didn't have any of the employees set to 'Yes'.

    The code works great when I have 1 or more selected thank you very much!

  14. #14
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Could this code be used to export the forms only to a file in word format? Maybe have another button?

    I hope I am not asking too much.

  15. #15
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    This macro will save the memo and each employee's sheet to Word. Please look at the comments I inserted in the code, particularly the one at the top regarding the reference to the Microsoft Word Object Library.
    Please Login or Register  to view this content.

  16. #16
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    It stops at this line error:

    Dim wrdApp As Word.Application


    Do I have to set up a file ?

  17. #17
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    It says user defined type not defined

  18. #18
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    I set up a file for the location:

    U:\Old User FIles\REPAIR STATION\Repair Station Training

    Will this be needed for the code?

  19. #19
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    This is what I tried:

    Please Login or Register  to view this content.

  20. #20
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    Have you added the reference to the Microsoft Word Object Library?

  21. #21
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    I guess I didn't. How ?

  22. #22
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Tools then References part is grayed out

  23. #23
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Okay I exited the debug and enabled Microsoft Word.

    Now it opens word and has the form and memo with the employee selected. The page margins are all different and I will have to adjust them I guess to fit the pages. I thought they would go to the file location chosen in the code?

    Sorry for all the trouble I am learning so much from you though.

  24. #24
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    I have tested the macro and it works properly. It should save the files according to the folder path in the code. Is it not doing that?

  25. #25
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    yes it is I put the wrong path.

    How can I adjust the margins? So what prints from excel and word are the same?

  26. #26
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Could they be set to fit page?

  27. #27
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    I really appreciate your patience with me. I tried it with 2 employees and it does print out each form with the names of those employees as the document names. Can the memo be named as 'Memo' instead of what I think it's doing is putting my name as the document name.

  28. #28
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    I noticed another thing happening. If I run it again the word documents get replaced.

  29. #29
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    The only way to prevent the Word documents from getting replaced is to change the saveas filename before you run the macro each time. What I have done is I included the date from cells G4 as part of the filename. Before you run the macro a second or third or more times, change the date in G4. In this manner, you will get multiple copies based on the date in G4. This macro should also auto fit the columns in the Word document.
    Please Login or Register  to view this content.
    Please change the folder path to match yours.
    Last edited by Mumps1; 01-19-2018 at 03:12 PM.

  30. #30
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Thank you that makes better sense although the word documents don't fit on one page and the centering texts are different.

    Would it be better to export to pdf so the image is scaled the same?

    I have been so much trouble for you sorry.

  31. #31
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    I attached the file for your review if you would be so kind.

    The print area changes sometimes and only prints the memos. Maybe the print preview buttons are interacting?

  32. #32
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    I tried the Form and Memo Print Preview buttons and they both seem to be working right according to the print area defined in each macro.

  33. #33
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Yes they do but when I select the 'All Forms and Memo Print Out' the print area is reduced to only print the memos.

  34. #34
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    Replace your current macro with this one.
    Please Login or Register  to view this content.

  35. #35
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    It prints one memo and all the forms. The print areas are corrected now but it should have one memo for each employee please.

    Thank you

  36. #36
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    Try:
    Please Login or Register  to view this content.

  37. #37
    Banned User!
    Join Date
    09-26-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    607

    Re: Generate All Forms and Memos From Macro

    Perfect thank you so much for your help.

    I will mark this thread closed and try to figure out how to save the forms as pdf on another thread.

    I have taken up so much of your time I hope to repay the favor some how one day.

  38. #38
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Generate All Forms and Memos From Macro

    You are very welcome.

+ 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. Replies: 0
    Last Post: 07-16-2015, 07:51 AM
  2. Generate reports through advanced USER FORMS!!
    By meus in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-20-2015, 12:35 AM
  3. generate certificates from templates/forms
    By Imad1965 in forum Word Formatting & General
    Replies: 7
    Last Post: 03-03-2013, 04:19 PM
  4. Print on ready blank forms (document forms)
    By gandrinno in forum Excel General
    Replies: 1
    Last Post: 02-16-2009, 06:12 PM
  5. Macro to generate forms from database
    By katrlow in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2007, 12:49 PM
  6. [SOLVED] Excel forms - authorise / deny forms
    By Ian Manning in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2006, 12:10 PM
  7. [SOLVED] Automatically generate user forms
    By Rominall in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2006, 09:25 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