+ Reply to Thread
Results 1 to 30 of 30

RUN a mail merge (Word file) from a USERFORM in EXCEL

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi. I just need HELP!..I'm new in this forum and I hope I'll find a kind soul to give me a hand with this. I have created a user-form used to input info from clients, after all info is in I need to run a Merge from word, the problem I'm having is that usually I need some other documents to be print, this is to be done not by me but by data entry employees, It would help me a lot to run the macro form the command button..please see the attached files.
    Attached Files Attached Files
    Last edited by alopecito; 09-05-2012 at 01:01 PM.

  2. #2
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito
    Welcome to the Forum!!!
    Your VBA Project appears to be password protected.
    What you wish to do can likely be done. Either unprotect the VBA Project or provide the password and we'll see what we can do.
    Last edited by jaslake; 09-06-2012 at 05:02 PM.
    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.

  3. #3
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    I'm sorry I forgot to remove the security passcode, use code42

    Thanks!

  4. #4
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    Place the two attached files in the same folder.

    The code in Module1 of TEST GRID Orig will run a MailMerge from Excel to Word and the attached MERGE DOC TEST File. The MERGE DOC TEST File is NOT the original file you uploaded. If not already set (it should be), you'll need to set a reference to Microsoft Word 12.0 Object Library (in VBA Tools--->References--->Microsoft Word 12.0 Object Library).

    I don't have a clear idea of what you want to print or where you wish to print from. This code prints ALL Form Letters and can be run from the Button in Cell D1. The formatting in the Form Letters is a bit screwed up but can be fixed...if you need help with that let me know.

    Let me know of issues.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Thanks!!!, I think is a good start!...

  6. #6
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    You're welcome...glad to be of help. If this resolves your issue please mark your Thread as SOLVED.

  7. #7
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi Jaslike, I run the Macro and Is good, but if I'm not taking to much of your time I need 2 adjustments...I use the userform1 in the Macro to write different documents, Userform1 insert all this data in the tab Fields-contract, I did insert your code and works perfectly calling up the Merge, the first adjustment is that I need to be able to print just the unit I'm writing currently, not the whole thing. Also since your code call the merge do you know how to insert the "confirm file format conversion on open" and choose MS Excel worksheets via DDE(*.xls) format?..That will resolve the format problem...Thanks!!!

  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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    The code in the attached addresses this
    I need to be able to print just the unit I'm writing currently, not the whole thing
    .
    The Merge Doc has been modified to accommodate the formatting. I'm not familiar with this
    you know how to insert the "confirm file format conversion on open" and choose MS Excel worksheets via DDE(*.xls) format
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Works perfectly!!!..just last thing, it open the document with what I need, If I want to just print the document and right after close it, Is that something possible?...Again, you're code is amazing thanks!!

  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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    Replace the code in Module1 with this code...I've indicated the Lines of Code added to do this
    I want to just print the document and right after close it
    In addition, I assumed you wish to close Word.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Voila!!..Merci..the code is amazing...I will change the status to solve...Again THANKS!!

  12. #12
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    You're welcome...glad I could help.

  13. #13
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    HI Jaslike, Just a quick last question...I use the code to print my merge but I need to print 2 copies...The code currently print one copy...Could you please help me?..this is the code you wrote..

    Please Login or Register  to view this content.
    best regards,

  14. #14
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    Change this line of code
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    : Compile error:
    User-defined type not defined[/QUOTE]

    Open your Excel File...go to VBA (Alt + F11) or however you prefer. In VBA Click on Tools--->References. Make certain you have a Reference set to Microsoft 12.0 Object Library (or whatever version is available). Set the Reference and run the code. Get back to me (in your Thread if you will please).
    .
    Thanks Jaslike, I did check and is set in Microsoft 14.0

    I did run the code and is the same...

  16. #16
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    What is the same? Are you still getting this Error Message?
    Compile error:User-defined type not defined

  17. #17
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Yes I do!!

  18. #18
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    I did set it again and... is printing...Dude, you save my live!!!,,THANKS!!

  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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    The error
    Compile error:User-defined type not defined
    would indicate that a Reference is not set. This is a picture of the References in my file References.jpg

    What does your's look like?

  20. #20
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    I didn't quite save your life but I appreciate the sentiment. Are you getting two copies?

  21. #21
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Thanks I think I was choosing the wrong Microsoft object, when I set the Word one, it works!. Thanks again!

  22. #22
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Yes, also I'm printing 2 copies of my documents...

  23. #23
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Great...you're welcome...glad it's working for you. If you wish to express gratitude see my signature. It explains how to do so.

  24. #24
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    My friend, sorry to be such a pain in the butt, but I have another issue and I don't know what is wrong(?))...When I print I the merge I did notice the format problem again, I tried again with the sample you did and works perfect!, I even printed the word doc (sample)using the my complete version of it and it works perfectly, but when I print the final docs I need the format is way off, the numbers are very weird...this time I attached the files..I guess the problem is in the word document, I did check all I know and is the same...Again, sorry but I'm afraid I have to ask you again for help, this needs to be working for my meeting tomorrow morning!...
    Attached Files Attached Files

  25. #25
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    When I run the code on you're new attached files I get a 5 page document. I have no idea what the formatting SHOULD look like. It all looks a bit weird to me but the NUMBER formatting on page 3 (actually labeled as - 16 - is not as it should be(228000.25, 40.012500000007) etc.

    As I said in an early post the Word Doc is NOT your original Doc...I made formatting changes to it (specifically the Numbers). These same changes will need to be made to your CONTRACT PETERSON ENG.doc.

    So, what're we talking about...what formatting are you concerned with...ONLY the numbers?

  26. #26
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    well, I guess this is why my docs are not the same!, I tried to format numbers in a Word doc merge before, the only way I found is by converting the file while opening, I guess there is another way!...the page's format is ok, but the numbers and dates are not...maybe formatting the final doc is just enough....Please let me know hot format the Word document, I guess that will do it...!
    Thanks again...sorry for my lack of experience , I'm glad I found this forum!

  27. #27
    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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    I'm doing the "Numbers" as we speak. No idea about the dates...need to look at them...where are they so I don't need to look for them?

  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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    Replace your Peterson document with the attached...the Number Formatting has been fixed (I think). Don't know about dates. TEST IT BEFORE your meeting...good luck.
    Attached Files Attached Files

  29. #29
    Registered User
    Join Date
    09-05-2012
    Location
    Montreal QC
    MS-Off Ver
    Office 365
    Posts
    25

    Re: RUN a mail merge (Word file) from a USERFORM in EXCEL

    I did check the dates in other doc I did print and the dates are OK..Just the numbers in Page 16...
    Again many thanks!...May I ask. How did you do it?

  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: RUN a mail merge (Word file) from a USERFORM in EXCEL

    Hi alopecito

    Grunt work...pure and simple. I had applied some formatting to Merge Doc Test based on some formatting I'd done previously in a personal project. That change I made to Merge Doc was working. So, for the most part, I copied/pasted that formatting to the Peterson Document (wasn't quite that simple but essentially that's what I did).

    You can look at the formatting code for each Number Field and see what the code for a particular Field is...don't ask me HOW/WHY it works...I only know it does.

    Best of luck in your meeting in the AM...TEST THIS TONIGHT. Let me know how you make out in the AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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