B
Brian Knittel
I'm having problems with a VBA application I've written using macros and
Forms,
where the Documents collection appears to be corrupt -- a given document
will
appear in it more than once, and another not at all. For example, with the
following documents open:
UCT0816A.DOC
UCT0816B.DOC
UCL0816A.DOC
textentry.doc
after the app has been running a while, the following VBA snippet
for each doc in Application.Documents
Selection.TypeText doc.name & VbCR
next
might print
UCT0816A.DOC
UCT0816B.DOC
textentry.doc
textentry.doc
or some variation on this theme. The count is always correct, but
the document objects are not always unique. I can view the doc object
in the debugger inside the "for each" loop and see that it's definitely an
exact
duplicate of one of the documents. Content is the same, etc,
so it's not the case that I've simply changed the Name property of one
of the open documents. Word's "Window" menu does show the four
distinct filenames. The collection really is wrong.
All of these documents are attached to the same template (.dot file)
although
they mght have been created at different times, saved, and later reopened.
This is happening on Word 97 SR-2, Word 2003 SP2 and possibly other
versions.
Does this ring any bells for anyone? Is it possible that something I'm doing
is explicitly corrupting the Documents collection?
Thanks
Brian
Forms,
where the Documents collection appears to be corrupt -- a given document
will
appear in it more than once, and another not at all. For example, with the
following documents open:
UCT0816A.DOC
UCT0816B.DOC
UCL0816A.DOC
textentry.doc
after the app has been running a while, the following VBA snippet
for each doc in Application.Documents
Selection.TypeText doc.name & VbCR
next
might print
UCT0816A.DOC
UCT0816B.DOC
textentry.doc
textentry.doc
or some variation on this theme. The count is always correct, but
the document objects are not always unique. I can view the doc object
in the debugger inside the "for each" loop and see that it's definitely an
exact
duplicate of one of the documents. Content is the same, etc,
so it's not the case that I've simply changed the Name property of one
of the open documents. Word's "Window" menu does show the four
distinct filenames. The collection really is wrong.
All of these documents are attached to the same template (.dot file)
although
they mght have been created at different times, saved, and later reopened.
This is happening on Word 97 SR-2, Word 2003 SP2 and possibly other
versions.
Does this ring any bells for anyone? Is it possible that something I'm doing
is explicitly corrupting the Documents collection?
Thanks
Brian