View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim of Calgary Tim of Calgary is offline
external usenet poster
 
Posts: 1
Default Excel Macro to Auto-Populate a Word Template

That's a bit of a poser. Normally I would use the strategy of pulling the
data straight into Word and let the Word Document run the process, since it
is the furthest downstream. However, if Excel is running things I can at
least steer you in the right direction, I hope.

This is designed so just about everything is done by the properties of the
document and only minimal VBA is needed.

1. Set up the Word document as a mail-merge drawing from your spreadsheet
(this works best if your data is pulled to a consistent place in the Excel
Sheet).

2. Create a macro in the Word document (not in Normal.dot) something like
this:

Sub AutoOpen()
ActiveDocument.Fields.Update
End Sub

If you have set up the mailmerge fields properly, this should update
everything to match your data source (i.e. the Excel document). Bob's your
uncle. You may have to create a tab in your Excel document called "datatab"
or something like that to hold the data in a form Word likes.

Now, as to opening the Word document from Excel, I must leave that to the
Cross-Application wizards; I am a single-application geek.

I hope this helps somewhat...

Tim Smith.


"Dan Thorman" wrote:

I am using Excel to pull data together from multiple sources, and am trying
to set it up as, essentially, a dashboard for a user. I have it set so that
the user hits a button and all the data that they need is automatically
pulled in to the workbook. However, I have a MS Word form that I would like
the data to be pushed to, and I cannot figure out how to write the macro to
automatically populate that particular form. I would normally just write the
macro so that it created the document from scratch every time, but there is a
LOT of static data in the form, and it changes often.

I am using Excel 2003

Can anyone provide an example of the code for how to do this? I am very new
to VBA programming (and not a programmer by trade), so an example should
allow me to figure out how to make it work in this particular instance.

Thanks in advance for all your help!