Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Lee Lee is offline
external usenet poster
 
Posts: 33
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a day timer template in word or excel? Lisa Excel Discussion (Misc queries) 1 January 9th 13 09:03 PM
Controlling word wrap in a cell Victor Delta[_2_] Excel Discussion (Misc queries) 2 February 14th 10 10:58 PM
How can I link between a Word template and an Excel template Josh Excel Discussion (Misc queries) 0 April 1st 08 12:36 AM
Opening a Word template from excel RealmSteel Excel Discussion (Misc queries) 3 November 29th 06 09:16 PM
Sending from excel to word template pizdus Excel Discussion (Misc queries) 0 January 17th 06 05:57 PM


All times are GMT +1. The time now is 09:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"