View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
leaftye leaftye is offline
external usenet poster
 
Posts: 1
Default Automate new Word file and insert autotext


I'm trying to use Excel to automate the creation of a new Word file
using a premade Word template. It makes the new Word file, but breaks
on the last line where I try to insert my autotext. Please review and
help me fix what I'm doing wrong. Also, if it matters, I also intend to
mailmerge this Word doc to the active Excel file. The autotext
definitely exists, so I must be calling it incorrectly. Thanks for
helping!


Dim objWord As Word.Application

Set objWord = CreateObject("Word.Application")
If Err Then
Set objWord = New Word.Application
End If

objWord.Visible = True
objWord.Activate

objWord.Documents.Add Template:="c:\templates\template.dot",
NewTemplate:=False, DocumentType:=0

objWord.ActiveDocument.AttachedTemplate.AutoTextEn tries("FORMS").Insert
Whe=Selection.Range, RichText:=True




--
leaftye