+ Reply to Thread
Results 1 to 9 of 9

Export data from Excel to Word doc using button

  1. #1
    Registered User
    Join Date
    09-12-2010
    Location
    Slovakia, EU
    MS-Off Ver
    Excel 2010
    Posts
    4

    Arrow Export data from Excel to Word doc using button

    Hello,

    Ok, I know it already had been discussed here and I tried to run code snippets published myself, but it was pretty complicated.

    Here's the thing:
    I have a worksheet with the data such as "ID", "Company Name", "Contact person", "Address", "Telephone", "Fax". Chances are, that I will need to add more "data types" in the future.

    There won't be multiple data entries, so there will be only one company (one row).

    The thing I want to be able to do after filling out all fields in Excel is to have some button that will say "Export to Word". After clicking on that button the Word document will be opened with data imported from Excel worksheet where I clicked the button. Can somebody help me?

    I already set up the test document (Word) where I predefined places where the data will be placed after clicking the button in Excel.

    I use Excel 2007 and I'm looking for some "universal" solution Just the basic stuff (not for me, Excel is not my cup of tea) that will create Word document with data from Excel after clicking on the button.

    Thank you for your time and help.

    Thomas

  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: Export data from Excel to Word doc using button

    Hi Thomas

    Take a look at this thread. I believe it addresses your issue.
    http://www.excelforum.com/excel-prog...erge-data.html
    Let me know if I can help.

    John
    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-12-2010
    Location
    Slovakia, EU
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Export data from Excel to Word doc using button

    Hi John,

    So I modified the code of excel workbook little bit, created document and set up the mail merge in it. The document (.docx) and .xlsm are stored in same folder. Unfortunatelly, when "Print All" button is pressed it gives me nothing but the error that the data could not be merged.

    Excel workbook and Word document is attached so if you or somebody will get some time to take a look on it and help me, it'll be much appreciated.

    Thank you

    Thomas
    Attached Files Attached Files

  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: Export data from Excel to Word doc using button

    Hi Thomas

    I'd need to know much more about what you're trying to do but, if you change this line of code in Public Sub PrintAll() from
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    your document does indeed merge.

    There is nothing in Column F; Column A will presumably always be populated. The reference will be to a column that will always be fully populated. Try this change. I'll help you however I can. You decide. Don't get terribly frustrated.

    John

  5. #5
    Registered User
    Join Date
    09-12-2010
    Location
    Slovakia, EU
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Export data from Excel to Word doc using button

    Thanks a lot for your help. I really appreciate it.

    Of course, I went through the code and didn't realize that I forgot to change it to A after I deleted other columns.

    One (I hope that the last question) ... I don't know if you realized, but now when I hit "Print All" button, it will create document that has the name "Form Letters 1" or something like that. Is there any way to change it to something specific?

    Thank you very much

    Thomas

  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: Export data from Excel to Word doc using button

    Hi Thomas

    Regarding this
    when I hit "Print All" button, it will create document that has the name "Form Letters 1" or something like that. Is there any way to change it to something specific?
    Yes, I realize this. Can you change the name to something specific? I'd assume so. I just don't know how to do so. . I generally print (or email) the resulting Word document. I'll need to research the question.

    I'll get back to you.

    John

  7. #7
    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: Export data from Excel to Word doc using button

    Hi Thomas

    How do you wish to do this? Via user input?
    when I hit "Print All" button, it will create document that has the name "Form Letters 1" or something like that. Is there any way to change it to something specific?
    John

  8. #8
    Registered User
    Join Date
    09-12-2010
    Location
    Slovakia, EU
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Export data from Excel to Word doc using button

    Hi John

    No, I want to just specify the file name (somewhere in the code).

    Thank you

    Thomas

  9. #9
    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: Export data from Excel to Word doc using button

    Hi Thomas

    In your code for "Sub PrintAll()" add this line of code
    Please Login or Register  to view this content.
    Hope this helps.

    John

+ 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