# Solved: Populate Word Document from Excel



## smartcard (Jun 1, 2007)

Hello,

I have an Excel sheet that contains data per row. At the end of each row, I want to put a button (or a hyperlink to a file) that will put the data from that row into a new Word document, something like a printer-friendly document.

Please find enclosed the Excel file and the DOC format that I need.


----------



## Rollin_Again (Sep 4, 2003)

The easiest way to do this is to create a generic Word "template" file and add form fields to it. Then you can use a button click event in your workbook that will fire some VBA code to transfer the info to your template. Do you want the resulting Word document to be automatically saved with a particular filename to a certain location or will simply displaying it be enough?

What version of MS Office / Excel / Word are you using?

Regards,
Rollin


----------



## Aj_old (Sep 24, 2007)

Smartcard, isn't easier to make a new sheet in Excel, in which you'll have the data arranged as you need? This in the case you need this only for printing!


----------



## smartcard (Jun 1, 2007)

> The easiest way to do this is to create a generic Word "template" file and add form fields to it. Then you can use a button click event in your workbook that will fire some VBA code to transfer the info to your template.


Yes, this is the option I need, but sorry I am not good at VBA codes.



> Do you want the resulting Word document to be automatically saved with a particular file name to a certain location or will simply displaying it be enough?


Not very important to save, simply pop up the DOC file while clicking the said button will be sufficient.



> What version of MS Office / Excel / Word are you using?


MS Office 2003 SP3

Thanks a lot.


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> Smartcard, isn't easier to make a new sheet in Excel, in which you'll have the data arranged as you need? This in the case you need this only for printing!


No, I don't need new sheet in Excel, I need the Word file to be created using a single row data from the Excel.


----------



## Aj_old (Sep 24, 2007)

How many rows of data you can have in the sheet?
What you'll say if will be used only one button, and it will transfer the data from the selected row to Word, or a button to the end of each row is the only way you wanna it be done?


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> How many rows of data you can have in the sheet?
> What you'll say if will be used only one button, and it will transfer the data from the selected row to Word, or a button to the end of each row is the only way you wanna it be done?


The sheet will have growing number of row's now it may have 30 but later will will increase even upto 1000

I believe one button approach would be fine.


----------



## Aj_old (Sep 24, 2007)

Try the file I uploaded!
Select one cell from the row you need to export to word, and hit the "Export to Word" button!
It will create a new word doc (if word application is not running it will start it) with the data you need in it!


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> Try the file I uploaded!
> Select one cell from the row you need to export to word, and hit the "Export to Word" button!
> It will create a new word doc (if word application is not running it will start it) with the data you need in it!


This is great, but can we have the data populated to a Word template? meaning I will have Word file with other text etc., and this row data will be inserted in to its positions.


----------



## Aj_old (Sep 24, 2007)

smartcard said:


> This is great, but can we have the data populated to a Word template? meaning I will have Word file with other text etc., and this row data will be inserted in to its positions.


You want data to be added into a word file, which already exist and has some data in it, or just put data into a new word file created on a specific template?


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> You want data to be added into a word file, which already exist and has some data in it, or just put data into a new word file created on a specific template?


I want data to be added into a word file, which already exist and has some data in it.


----------



## Aj_old (Sep 24, 2007)

smartcard said:


> I want data to be added into a word file, which already exist and has some data in it.


Where data should be added? What is the structure of the doc? Name, and so on! Is doc open or excel should open it?

If it's posible post a sample!


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> Where data should be added? What is the structure of the doc? Name, and so on! Is doc open or excel should open it?
> 
> If it's posible post a sample!


Please find enclosed sample doc. I want to keep this DOC as a template and once the button clicked the data will be filled here. I think in that case the DOC should have book marks for fallible data fields?


----------



## Aj_old (Sep 24, 2007)

Smartcard the same question again!
Why having this on a separate worksheet in excel isn't good for you!
The doc file will be send to someone or just used fro printing?


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> Smartcard the same question again!
> Why having this on a separate worksheet in excel isn't good for you!
> The doc file will be send to someone or just used fro printing?


Good idea to keep it on a separate worksheet, but some times Excel is difficult to format to print etc.,


----------



## Aj_old (Sep 24, 2007)

Try this!


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> Try this!


Thanks, this is cool. But I was expecting that I can modify the DOC template the way I want, like adding more fields, repositioning the fields etc.


----------



## Aj_old (Sep 24, 2007)

You can change it! The data will be allways stored in the second cell of the second row of the first table, at the 3 paragraph! Everything else can be changed


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> You can change it! The data will be allways stored in the second cell of the second row of the first table, at the 3 paragraph! Everything else can be changed


Thanks, I will try it.

Is it easy to do the "separate worksheet" data population than using the DOC?


----------



## Aj_old (Sep 24, 2007)

smartcard said:


> Is it easy to do the "separate worksheet" data population than using the DOC?


It depends on what you wanna be on that sheet. In many cases it's easier to make a separate sheet, than to export to word!


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> It depends on what you wanna be on that sheet. In many cases it's easier to make a separate sheet, than to export to word!


Please find in the enclosed I have created the 2nd sheet how the populated sheet should look like, the Yellow highlighted cells will have data from the main sheet.


----------



## Aj_old (Sep 24, 2007)

Is this fine?


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> Is this fine?


This is very very cool, that is what I wanted :up:

Please tell me if I need to do some modification should I use Macros or any other way?


----------



## Aj_old (Sep 24, 2007)

smartcard said:


> This is very very cool, that is what I wanted :up:
> 
> Please tell me if I need to do some modification should I use Macros or any other way?


I proposed from the stat to use, excel, you said no!
It is done using a macro, and if the data structure is change the macro should be changed too!


----------



## smartcard (Jun 1, 2007)

Aj_old said:


> I proposed from the stat to use, excel, you said no!
> It is done using a macro, and if the data structure is change the macro should be changed too!


You are correct, its my mistake not considering your proposal.

I have seen the codes from Tools | Macros | Visual Basic Editor

Please tell me how to remove the "Export to Word" Button

Also I need to know how can I copy this VB script (macro) to another new Excel file?

Thanks for your help.


----------



## Aj_old (Sep 24, 2007)

smartcard said:


> Please tell me how to remove the "Export to Word" Button


Go to Tools/Macro/Visual Basic Editor, in editor hit Run\Design Mode, return to Excel, right click the button and select delete or just click on it and hit delete



smartcard said:


> Also I need to know how can I copy this VB script (macro) to another new Excel file?


Copy the sheet, right click on the sheets tab, select "Move or Copy...", check the "Create a copy", select the workbook you wanna sheet to be copied to, and press OK. (For a new Workbook select "(new book)"!


----------

