L
Lee
I have an Excel add-in that I use to open a Word template
and populate tables in the document with data from Excel.
I would like to insert AutoText saved in the template
before the tables are populated with data, but I cannot
figure out the correct syntax to automate this in Excel.
I tried posting this question on one of the Excel
newsgroups, but it was suggested I should try the Word NGs
instead.
Here is the code I am currently using:
Sub TextTest()
Dim WordApp As Word.Application
Set WordApp = CreateObject("word.application")
WordApp.Visible = True
With WordApp
Documents.Add Template:= _
"C:\Documents and Settings\all
users\Templates\rxtemptest.dot" _
, NewTemplate:=False, DocumentType:=0
.Selection.Goto what:=wdGoToBookmark,
Name:="PlaceMark"
.ActiveDocument.AttachedTemplate.AutoTextEntries
("Temp1").Insert Where:=Selection.Range, RichText:=True
End With
Set WordApp = Nothing
The code is breaking on the line that
begins .ActiveDocument, and it is giving me error code
450, Wrong number of arguments or invalid property
assigned. Can someone suggest the proper syntax?
Thanks, Lee
and populate tables in the document with data from Excel.
I would like to insert AutoText saved in the template
before the tables are populated with data, but I cannot
figure out the correct syntax to automate this in Excel.
I tried posting this question on one of the Excel
newsgroups, but it was suggested I should try the Word NGs
instead.
Here is the code I am currently using:
Sub TextTest()
Dim WordApp As Word.Application
Set WordApp = CreateObject("word.application")
WordApp.Visible = True
With WordApp
Documents.Add Template:= _
"C:\Documents and Settings\all
users\Templates\rxtemptest.dot" _
, NewTemplate:=False, DocumentType:=0
.Selection.Goto what:=wdGoToBookmark,
Name:="PlaceMark"
.ActiveDocument.AttachedTemplate.AutoTextEntries
("Temp1").Insert Where:=Selection.Range, RichText:=True
End With
Set WordApp = Nothing
The code is breaking on the line that
begins .ActiveDocument, and it is giving me error code
450, Wrong number of arguments or invalid property
assigned. Can someone suggest the proper syntax?
Thanks, Lee