Word Template Q (Automation)

snowman

Registered User.
Local time
Today, 13:29
Joined
Mar 3, 2006
Messages
24
Hey guys

Firstly, my Access-Word automation is working fine. however, ive run into a new problem now.
(im using templates and bookmarks) - when i export the data from access to my template, the information is not stored in a new document, instead the template is opened and the data inserted into it. and for saving (manual, not automatic) the first option is to overwrite the original template as a .dot file

obviously this is not great - what do i need to do to get my automation to open the template, but insert the data into a new instance of word, and not into the original template file?

the code im using to call and open the template is below:


Dim wrdApp As Object
Dim wrdDoc As Object

Set wrdApp = CreateObject("Word.application")
Set wrdDoc = wrdApp.Documents.Open("C:\Final Yr Project\Templates\ShippingNotice.dot")

what do i need to include / change so that i can get this ?

thanks
 
You probably want to use WrdApp.Documents.Add()

From the Word Help files:
Code:
Add method as it applies to the Documents object.

Returns a Document object that represents a new, empty document added to 
the collection of open documents.

expression.Add(Template, NewTemplate, DocumentType, Visible)
expression
    Required. An expression that returns a Documents object.

[B]Template   Optional Variant. The name of the template to be used for the new
 document. If this argument is omitted, the Normal template is used.[/B]

NewTemplate   Optional Variant. True to open the document as a template. 
The default value is False.

DocumentType   Optional Variant. Can be one of the following WdNewDocumentType 
constants: wdNewBlankDocument, wdNewEmailMessage, wdNewFrameset, or wdNewWebPage. 
The default constant is wdNewBlankDocument.

Visible   Optional Variant. True to open the document in a visible window. If this value 
is False, Microsoft Word opens the document but sets the Visible property of the 
document window to False. The default value is True.
 
thanks a million for that mate, it worked like a charm!
 

Users who are viewing this thread

Back
Top Bottom