+ Reply to Thread
Results 1 to 12 of 12

Exporting excel data to word template

  1. #1
    Registered User
    Join Date
    10-30-2013
    Location
    Leicestershire
    MS-Off Ver
    Excel 2003
    Posts
    16

    Exporting excel data to word template

    Hi Everyone,

    I would really appreciate some help on the issues that I have been struggling on.

    I am creating a performance management system on excel and as part of this system I would like to be able to generate reports based on microsoft word templates. Therefore I would like to press a button and word is opened and the template populated.

    I have been searching the internet and researched the use of book marked fields in the word document. I have tried the code on these threads but they have not worked. Please could someone help as I consider this advanced vba coding and not something I am normally used to.

  2. #2
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: Exporting excel data to word template

    Hello there
    Could you post a sample of the report and the spreadsheet, and we can throw some code together to make them talk. No sensitive info, just the skeleton of the templates.

    Regards
    Most helpful to mark solved items as such (see help for directions). Star ratings are always welcome.

  3. #3
    Registered User
    Join Date
    10-30-2013
    Location
    Leicestershire
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Exporting excel data to word template

    Hi,

    Thank you so much, you are a true life saver.

    I have attached a sample copy of the excel spreadsheet & template.

    If you have any questions let me know.Sample Monthly Reporting.xlsTemplate.doc

  4. #4
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: Exporting excel data to word template

    report1.xlsTemplate.doc

    Hello
    There are a couple things to get this working. The VBA actually sits in Word and goes out to fetch the data to plug back into the template.

    In Word there are 2 controls inserted, the 1 is a label and the other is a button. The label is the placeholder for the data while the button runs the VBA and gets the data.

    Tips : be careful that the file location is correct, that the cell position is right. To change existing controls or add new ones, you need to go to "Developer" tab and select "Design mode". The controls are in "legacy tools" just below the Design mode

    Have a look and see if you can extent to the rest of the data fields. I renamed the spreadsheet to make the name easier.

    Regards

  5. #5
    Registered User
    Join Date
    10-30-2013
    Location
    Leicestershire
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Exporting excel data to word template

    Hi

    I think what you have done is great. I am just having problems getting it to work. I have changed the location of both - 1) I have changed the template and placed into our F Drive and the excel document into my personal files but the code returns "Caqnnot find project or library". Code is below

    report1.xlsTemplate.doc
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: Exporting excel data to word template

    Hello
    When the code stops and gives the error, if you select to debug - does it take you to the line : Set exWb = objExcel.Workbooks.Open("C:\Documents and Settings\msmith\My Documents\report1.xls") ?

    I also have to create a reference to Excel in Word :
    > go to developer menu
    > Visual Basic (on left side)
    > in the new window, go to Tools
    > References
    > Available reference list, select the Microsoft Excel object library

    What version of word and excel you using ?

    Regards

  7. #7
    Registered User
    Join Date
    10-30-2013
    Location
    Leicestershire
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Exporting excel data to word template

    Hi,

    Yes it is that line that is highlighted.

    I am using Ecel and Word 2007.

    Which one in that list of projects do I need to select?

  8. #8
    Registered User
    Join Date
    10-30-2013
    Location
    Leicestershire
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Exporting excel data to word template

    Hi

    On the list of references I have the message:

    MISSING Microsoft Excel 14.0 Object Library

    Do I need to get the company I work for to install this?

  9. #9
    Registered User
    Join Date
    10-30-2013
    Location
    Leicestershire
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Exporting excel data to word template

    thank you very much I have got them to install it and this works a treat.

    Thank you again.

  10. #10
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: Exporting excel data to word template

    That is great, you could try to use that as a pattern for the other fields.

    If you feel you are happy with this, please mark post as solved.

    Regards

  11. #11
    Registered User
    Join Date
    10-30-2013
    Location
    Leicestershire
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Exporting excel data to word template

    I am now getting a run-time error '1004' with that code.

    Could it be that the excel sheet that I have now got the word.doc to draw information from has macros running
    ?

  12. #12
    Forum Contributor
    Join Date
    01-07-2013
    Location
    south africa
    MS-Off Ver
    Excel 2003-13
    Posts
    210

    Re: Exporting excel data to word template

    Hello
    Perhaps you could post the full line of the error message - it may have some description after error 1004

    It is usually not finding something, perhaps check that spreadsheet was not moved or anything renamed. And your word still has the reference to micorsoft excel object library
    Perhaps also check that you don't have the spreadsheet opened at the same time that word is trying to open it - I am not sure if word will use existing open spreadsheet or the call will fail ?

    Perhaps your suggestion of macros needing to be enabled, maybe it is getting stuck with the opening.
    On Excel 2010, I can go to trusted centre and change the settings to open files with macros without disabling the macros - perhaps fiddle there

    Regards

+ 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] Exporting specific data from Excel to Word
    By matt198992 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-28-2014, 02:50 AM
  2. [SOLVED] Exporting data from master file to pre-populate many excel files from a template
    By Gti182 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-07-2013, 07:52 AM
  3. exporting data from excel into word
    By rwise in forum Excel General
    Replies: 2
    Last Post: 07-16-2008, 04:47 PM
  4. exporting data from excel into word
    By pboost1 in forum Excel General
    Replies: 16
    Last Post: 06-12-2008, 03:37 PM
  5. exporting Excel data to MS Word...
    By bl!zzarD in forum Excel General
    Replies: 1
    Last Post: 07-27-2007, 02:09 PM

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