Hi Cindy, hi all!
Using vbscript, I open a document and a template as a document which I
attach to it using myOpenedDoc.AttachedTemplate = app.Documents.Open(..).
Now, as Cindy explained to me,
I do need to have some way to explicitly UNLOAD (close) the template.
Especially if this is NOT 2003. In earlier versions this was the source of
some really bad memory leaks and other problems.
> However
> how can I find when to close it if this is necessary?
Well... this code I'm placing in the template:
Private Sub Document_Close()
If ThisDocument = ActiveDocument Then Exit Sub
Dim doc As Document
For Each doc In Documents
If doc.AttachedTemplate = ThisDocument Then Exit Sub
Next doc
ThisDocument.Close False
End Sub
Is this the right way?
Thanks,
Jan
Jan Kucera - 21 Sep 2006 16:14 GMT
Okay there is a bug because the document being closed is also included in
the collection, but otherwise it seems to work quite ....hey wait i minute,
the template is being attached to itself as well?? :-)
> Hi Cindy, hi all!
> Using vbscript, I open a document and a template as a document which I
[quoted text clipped - 24 lines]
> Thanks,
> Jan