Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Controlling Word template from Excel
I have an Excel add-in from which I can open a Word
template and insert info from the Excel workbook. I am trying to insert AutoText that is saved in the template, but I can't find the right syntax. This is what I have written: 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 WordApp.Selection.Goto what:=wdGoToBookmark, Name:="PlaceMark" WordApp.Selection.Insert("temp1").InsertAutoText Whe=Selection.Range, _ RichText:=True End With What am I doing wrong? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Controlling Word template from Excel
"Lee" wrote in message ... I have an Excel add-in from which I can open a Word template and insert info from the Excel workbook. I am trying to insert AutoText that is saved in the template, but I can't find the right syntax. This is what I have written: 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 WordApp.Selection.Goto what:=wdGoToBookmark, Name:="PlaceMark" WordApp.Selection.Insert("temp1").InsertAutoText Whe=Selection.Range, RichText:=True End With What am I doing wrong? I don't know, but I have two suggestions that may be helpful and one that is probably wrong: 1. Your query is really to do with Word VBA code - why not try one of the more relevant NGs? You will be more likely to get a helpful response. 2. We have an office app that does something similar. It actually runs a mailmerge and then edits the resultant document within Word. We found the best way was to set up a separate macro within word to do the editing. The Excel code can trigger the word macro and then leave it to do its own work. I seem to recall that it is far easier to debug the Word VBA code as a separate macro within Word. 3. My Word Macro recorder recorded this, and you may like to use it in place of the last line of your code: NormalTemplate.AutoTextEntries("temp1").Insert Whe=Selection.Range Incidentally, if you are using With WordApp ... End With, is it at all helpful to start two of the lines WordApp.? HTH a bit Geoff |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is there a day timer template in word or excel? | Excel Discussion (Misc queries) | |||
Controlling word wrap in a cell | Excel Discussion (Misc queries) | |||
How can I link between a Word template and an Excel template | Excel Discussion (Misc queries) | |||
Opening a Word template from excel | Excel Discussion (Misc queries) | |||
Sending from excel to word template | Excel Discussion (Misc queries) |