+ Reply to Thread
Results 1 to 13 of 13

How can I generate a Word file using an Excel file?

  1. #1
    Forum Contributor
    Join Date
    11-10-2011
    Location
    Bucharest, RO
    MS-Off Ver
    Excel 2016
    Posts
    118

    How can I generate a Word file using an Excel file?

    I have an excel file with several excel sheets. Each excel sheet contains one or more tables. Below I have exemplified an Excel file with only three sheets.
    Now, I would like to generate a MS Word file (.doc) - in fact a template .doc - that contains tables from whole Excel file, together with the data.
    Is there any way of doing this using VBA? Please.
    Attached Files Attached Files

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

    Re: How can I generate a Word file using an Excel file?

    Do you mean you want to insert the tables from the workbook in a new Word document?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    11-10-2011
    Location
    Bucharest, RO
    MS-Off Ver
    Excel 2016
    Posts
    118

    Re: How can I generate a Word file using an Excel file?

    Yes, but I want to do this thing automatically, not using copy-paste.

  4. #4
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: How can I generate a Word file using an Excel file?

    Something Similar...
    Please Login or Register  to view this content.
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  5. #5
    Forum Contributor
    Join Date
    11-10-2011
    Location
    Bucharest, RO
    MS-Off Ver
    Excel 2016
    Posts
    118

    Re: How can I generate a Word file using an Excel file?

    @Parth, thanks for the reply but isn't working, it showing the below error:

    "Compile error: user-defined type not defined" ???

  6. #6
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: How can I generate a Word file using an Excel file?

    This is Just an code for inputting the Sheet "Cat I" in word..

    You need to add refernce in excel..
    Open Excel
    press ALT + F11
    Then go to tools
    Then click References & select "Microsoft Word 14.0 Object Library" or anything similar to it & then run the code for sheet "Cat I"

  7. #7
    Forum Contributor
    Join Date
    11-10-2011
    Location
    Bucharest, RO
    MS-Off Ver
    Excel 2016
    Posts
    118

    Re: How can I generate a Word file using an Excel file?

    I checked the Reference tab options and there is checked (default) five options: Visual Basic for Applications, Microsoft Excel 14.0 Object Library, OLE Automation, Microsoft Word 14.0 Object Library and Microsoft Office 14.0 Object Library.
    I make mention that using Excel 2010. Now, after I checked "Microsoft Word 14.0 Object Library", if I try to run the macro, it displays the following error:

    Run time error '5174': Application defined or object-defined error

    Why? Please.

  8. #8
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: How can I generate a Word file using an Excel file?

    You should have a Empty Word file in D: drive location as below

    D:\Excel2Word.docx


    Now run the attached file code in modules & see
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    11-10-2011
    Location
    Bucharest, RO
    MS-Off Ver
    Excel 2016
    Posts
    118

    Re: How can I generate a Word file using an Excel file?

    Well, I respect your recommendations above but after I run excel macro and I open the Word file, this file is empty (ie, nothing happens). In your case is working?

  10. #10
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: How can I generate a Word file using an Excel file?

    Yes its working... it doesnt paste it in the file on d drive.. it rather creates a New word file & then saveas it in your folder where your macro file iexists..
    please check

  11. #11
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: How can I generate a Word file using an Excel file?

    Another approach is to 'pull' the data from Excel into Word. Instead of 'pushing' the data from Excel to Word.

    What about creating a blank template file or .dotm file in Word. And then copy / link the various charts you want from Excel into Word. You can then update all charts/ranges in the Word document pretty easily.

  12. #12
    Forum Contributor
    Join Date
    11-10-2011
    Location
    Bucharest, RO
    MS-Off Ver
    Excel 2016
    Posts
    118

    Re: How can I generate a Word file using an Excel file?

    Quote Originally Posted by ptmuldoon View Post
    Another approach is to 'pull' the data from Excel into Word. Instead of 'pushing' the data from Excel to Word.

    What about creating a blank template file or .dotm file in Word. And then copy / link the various charts you want from Excel into Word. You can then update all charts/ranges in the Word document pretty easily.
    You want to use a canvas excel in MSWord document and there was inserts tables using links from the original excel file? I tried this thing but isn't updating the information from the doc file, even if excel file is opened.

    @Parth007,
    I tried to run your example, but does not complete the Word file with an Excel file tables !!!! Please, attach files again.

  13. #13
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: How can I generate a Word file using an Excel file?

    Use this File...

    Store this file in any folder & then open it & run the code..
    You will see the output word file in the sasme folder..
    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. Dynamically Generate graph in an excel file from a .csv file [URGENT]
    By pushkarjajoria in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2013, 06:51 AM
  2. Excel 2007 : Generate word document from excel file
    By stevetothink in forum Excel General
    Replies: 5
    Last Post: 09-09-2011, 05:42 PM
  3. copy and generate a word file
    By W B H in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-22-2009, 05:26 AM
  4. generate word file from excel
    By memotronic in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-23-2005, 02:25 PM
  5. Replies: 0
    Last Post: 11-03-2005, 08:10 AM

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