Nicholas Glasier
Guest
|
I'm trying to create a new blank document based on the template of an existing document, but keep getting an error message "Wrong type"
var
intf: IDispatch;
IDoc, NewDoc: Word2000._Document;
ATemplate, isTemplate, aDocType, aVisible: OLEVariant;
begin
Intf := WordApp.ActiveDocument;
Intf.QueryInterface(Word2000._Document, IDoc);
if ExtractFileExt(IDoc.Name)= '.dot' then
isTemplate := true
else isTemplate := false;
ATemplate := IDoc.Get_AttachedTemplate;
aDocType := wdNewBlankDocument;
aVisible := true;
NewDoc := WordApp.Documents.Add(aTemplate, isTemplate, aDocType, aVisible);
The parameters are all olevariants as you can see, and debugging shows the code before the last line runs ok, but WordApp.Documents.Add raises a Type Mismatch error. What am I doing wrong please?
Nick |
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Hi Nick,
MSDN quotation:
---
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.
---
So, try to pass the attached template Name instead of the Template object.
|
|