I already answered this question for you. Did you follow the steps? Did you
enter a named range into Excel, and name it 'Address'? Did you create a
DocVariable in Word, and name it 'Address'? Did you add the reference to
Word from Excel? If not, look here for instructions on how to do this:
http://www.cpearson.com/excel/References.htm
You must have missed a step somewhere. i know that's how it is done; I've
done it many times.
Try again...
Goodluck,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
"sam" wrote:
Hi All, I want to populate a word template with data frome excel. I have
designed an "Export" button in excel sheet, which on clicking should populate
certain fields in a word file. Here is my code so far, But its not working!!
Any help would be highly appretiated.
Private Sub Export_Click()
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)
strTemplateName = "TestTemplate.dot"
strPathTemplateName = "C:\My Documents" & strTemplateName
Set objWord = CreateObject("Word.Application")
With objWord
.ActiveDocument.variables("Address").Value = Range("Address").Value
End With
objWord.Visible = True
Set objDoc = Nothing
Set objWord = Nothing
End Sub
Thanks in Advance