PDA

View Full Version : Excel to word



lifeson
11-24-2008, 10:00 AM
This has me stumped

I am using this to try and send some data from excel to word

The word document template has a bookmark named "customer" nothing else at all

but i get an error message
"Name" is read only property

What am I doing wrong?
(answer is probably using MSword :rotlaugh: :rotlaugh: )

Sub BuildQuote()
Dim customer As String
Dim oWord As Object, oDoc As Object
Dim fPath As String
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("TblQuoteLine")
fPath = "C:\Demo.dot"
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Open(fPath)
customer = "Fred"
With oDoc
.bookmarks("customer") = customer
End With
'close objects
Set oWord = Nothing
Set oDoc = Nothing
End Sub

lifeson
11-24-2008, 11:35 AM
This seems to work

With oWord.ActiveDocument
.Bookmarks("customer").Range.Text = customer
end with

Why dont I get any prompts though when trying to write the code?