S
sam
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
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