R
Rip West
I am trying to copy a routine written by Alan Simpson to print a contacts
address directly to a word document. I have created the word document with
bookmarks for FullName, Street, Address, and Salutation. When I run the
routine, the compiler balks on the 'with' items, saying 'invalid use of
property'. I know the routine finds the word document in question, because
if I rem out all the with items, the document is displayed. Routine is given
below. Any help appreciated.
Private Sub cmdMergetoWord_Click()
Dim strFullName, strSalutation, strStreet, strAddress As String
Dim Wrd As New Word.Application
Set Wrd = CreateObject("Word.Application")
Dim strMergeDoc As String
strMergeDoc = "C:\Users\rip\Documents\Data\word\OneContact.Dot"
'Open the word document, make it visible
Wrd.Documents.Add strMergeDoc
Wrd.Visible = True
With Wrd.ActiveDocument.Bookmarks
.item("FullName") = strFullName
.item("Street") = strStreet
.item("Address") = strAddress
.item("Salutation") = strSalutation
End With
Wrd.ActiveDocument.PrintPreview
End Sub
Rip West
Saint Paul, MN
address directly to a word document. I have created the word document with
bookmarks for FullName, Street, Address, and Salutation. When I run the
routine, the compiler balks on the 'with' items, saying 'invalid use of
property'. I know the routine finds the word document in question, because
if I rem out all the with items, the document is displayed. Routine is given
below. Any help appreciated.
Private Sub cmdMergetoWord_Click()
Dim strFullName, strSalutation, strStreet, strAddress As String
Dim Wrd As New Word.Application
Set Wrd = CreateObject("Word.Application")
Dim strMergeDoc As String
strMergeDoc = "C:\Users\rip\Documents\Data\word\OneContact.Dot"
'Open the word document, make it visible
Wrd.Documents.Add strMergeDoc
Wrd.Visible = True
With Wrd.ActiveDocument.Bookmarks
.item("FullName") = strFullName
.item("Street") = strStreet
.item("Address") = strAddress
.item("Salutation") = strSalutation
End With
Wrd.ActiveDocument.PrintPreview
End Sub
Rip West
Saint Paul, MN