ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   excell auto-populate word? (https://www.excelbanter.com/excel-worksheet-functions/247292-excell-auto-populate-word.html)

LUCHA

excell auto-populate word?
 
I am attempting to make a €œWord Document€ which has some blanks
auto-populated from an €œExcel Workbook€.

It would be best to create a €œWord Document€ to a sheet of an excel
workbook.
Am I on the right track?
How do I populate the blanks?


ryguy7272

excell auto-populate word?
 
Whoa! Looks like this is your first post ever, and you're posting in the
Excel Functions area, when you should really be posting this question in the
Excel Programming area. Oh well, I'll tell you how to do what you want to
do, but I feel it may take a little effort on your part to grasp everything.

How to send data from Excel to Word (using Fields):

In Word, click Insert Field DocVariable, then name your DocVariable.
Repeat as many times as necessary. In this example, I am using
€˜BrokerFirstName and €˜BrokerLastName. Basically, Im doing some analytics
in Excel, and preparing the results, in the form of a letter, to a
StockBroker, including the brokers first and last name and as many other
variables as necessary.


In Excel, hit Alt+F11, click Tools References check the reference for
Microsoft Word

xx.x Object Library. Then copy/paste this code into Excels Visual Basic
Editor window:

Sub PushToWord()
Dim objWord As New Word.Application
Dim doc As Word.Document
Dim bkmk As Word.Bookmark

sWdFileName = Application.GetOpenFilename(, , , , False)
Set doc = objWord.Documents.Open(sWdFileName)
'On Error Resume Next
objWord.ActiveDocument.variables("BrokerFirstName" ).Value =
Range("BrokerFirstName").Value
objWord.ActiveDocument.variables("BrokerLastName") .Value =
Range("BrokerLastName").Value
objWord.ActiveDocument.Fields.Update
'On Error Resume Next
objWord.Visible = True
End Sub

A few more examples for you...
Take a look at this:
http://word.mvps.org/FAQs/InterDev/C...WordFromXL.htm

This too:
http://addbalance.com/usersguide/fields.htm

And this:
http://gregmaxey.mvps.org/Word_Fields.htm

Finally, once you get the DocVariable fields set up in Word (hit Alt + F9 to
see all fields), run this code from Excel.
Sub PushToWord()

Dim objWord As New Word.Application
Dim doc As Word.Document
Dim bkmk As Word.Bookmark
sWdFileName = Application.GetOpenFilename(, , , , False)
Set doc = objWord.Documents.Open(sWdFileName)

With doc
..Variables("VarNumber1").Value = Range("VarNumber1").Value
..Variables("VarNumber2").Value = Range("VarNumber2").Value
'etc
..Range.Fields.Update
End With

'ActiveDocument.Fields.Update

objWord.Visible = True

End Sub

Note: This code runs in Excel; pushes Excel variables (assigned as Named
Ranges) to Word.

HTH,
Ryan--

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"LUCHA" wrote:

I am attempting to make a €œWord Document€ which has some blanks
auto-populated from an €œExcel Workbook€.

It would be best to create a €œWord Document€ to a sheet of an excel
workbook.
Am I on the right track?
How do I populate the blanks?


Geoff_L[_2_]

excell auto-populate word?
 
If you are using 07 then the process of linking is relatively simple.

Highlight the cells in Excel that you want to connect to Word and press
cntrl + C, to activate the copy function.

Go to the place in Word where you want this to appear and then click the
drop down menu below the Paste icon on the Home ribbon. Choose Paste Special.

You will now be presented with a Paste Special dialog box. Choose the Paste
Link option on the left hand side and then select the type of link that you
want to create. You will need to experiment with the formatting in both the
Excel document and the Word document as there are some issues here.

If this is helpful, please click Yes.

"LUCHA" wrote:

I am attempting to make a €œWord Document€ which has some blanks
auto-populated from an €œExcel Workbook€.

It would be best to create a €œWord Document€ to a sheet of an excel
workbook.
Am I on the right track?
How do I populate the blanks?



All times are GMT +1. The time now is 08:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com