#102123 - 2003-06-14 10:57 PM
Re: Open a created word doc, with a template...
|
kholm
Korg Regular
   
Registered: 2000-06-19
Posts: 714
Loc: Randers, Denmark
|
I believe this is closer to your needs.
Insert text into another document, where document one is used as template.
The function InsertInTemplate() Can insert at the end of the template, or at a bookmark in the template.
If you want to insert the document at a bookmark in the template, use the optional parameter $InsertPoint, this should be the name of a valid bookmark name in the template.
Second optional parameter, can be used to save the new document with a new name, and if the extention is .dot the new document is saved as a template.
code:
Break On InsertInTemplate('E:\MiscInfo.dot','e:\invoices\miscinfo\mydoc.doc',,'e:\invoices\miscinfo\myNewdoc.doc') Function InsertInTemplate($Template,$Document,Optional $InsertPoint,Optional $NewName) Dim $oWord $oWord = CreateObject('Word.Application') $RC = $oWord.Documents.Add($Template) ; Create new document based on $Template If $InsertPoint $RC = $oWord.Selection.GoTo(-1,,,$InsertPoint) ; GoTo Bookmark Else $RC = $oWord.Selection.EndKey(6) ; GoTo EndOfDocument EndIf $oWord.Selection.InsertFile($Document) If Not $NewName $NewName = $Document ; Overwrite the original document if $NewName is empty EndIf If Right($NewName,4) = '.dot' $oWord.ActiveDocument.SaveAs($NewName, 1) ; Save as Template Else $oWord.ActiveDocument.SaveAs($NewName, 0) ; Save as Document EndIf $oWord.Quit(0) EndFunction
A template in Word is not just text, so my first suggestion was meant as pointing a document back to a valid template, this can be nessasary if the template contains macros. An example: In some of the Word-templates on my net i have a macro that substitutes the Print key in Word and ask the user for a journalnumber before the printout is done.
-Erik [ 14. June 2003, 23:13: Message edited by: kholm ]
|
|
Top
|
|
|
|
Open a created word doc, with a template...
|
cmarti
|
2003-06-13 04:34 PM
|
Re: Open a created word doc, with a template...
|
Lonkero
|
2003-06-13 04:43 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-13 04:48 PM
|
Re: Open a created word doc, with a template...
|
Radimus
|
2003-06-13 04:53 PM
|
Re: Open a created word doc, with a template...
|
Lonkero
|
2003-06-13 04:56 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-13 04:59 PM
|
Re: Open a created word doc, with a template...
|
Shawn
|
2003-06-13 05:03 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-13 05:09 PM
|
Re: Open a created word doc, with a template...
|
Shawn
|
2003-06-13 05:14 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-13 05:17 PM
|
Re: Open a created word doc, with a template...
|
Shawn
|
2003-06-13 05:18 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-13 05:21 PM
|
Re: Open a created word doc, with a template...
|
Lonkero
|
2003-06-13 06:59 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-13 08:17 PM
|
Re: Open a created word doc, with a template...
|
kholm
|
2003-06-13 08:51 PM
|
Re: Open a created word doc, with a template...
|
NTDOC
|
2003-06-13 09:22 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-13 09:39 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-13 09:49 PM
|
Re: Open a created word doc, with a template...
|
NTDOC
|
2003-06-13 09:53 PM
|
Re: Open a created word doc, with a template...
|
NTDOC
|
2003-06-13 11:01 PM
|
Re: Open a created word doc, with a template...
|
NTDOC
|
2003-06-14 10:01 AM
|
Re: Open a created word doc, with a template...
|
kholm
|
2003-06-14 10:57 PM
|
Re: Open a created word doc, with a template...
|
NTDOC
|
2003-06-16 09:56 AM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-16 04:24 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-16 04:50 PM
|
Re: Open a created word doc, with a template...
|
cmarti
|
2003-06-20 08:17 PM
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 483 anonymous users online.
|
|
|