close document problem

W

ward

Hello,

I have the following problem that pop ups now and then:

When a user tries to close a document (which is based on a
template with some added VBA functionality), sometimes,
but not very often, the following message appears:

"This document can not be closed because it is referenced
by an open VBA project"

It is then impossible to close the document or even shut
down Word, because the message keeps popping up. Only way
out is using Window's Task Manager to kill Word.

I have no idea why and when this message now en then (very
rarely) appears, apart from that it has something to do
with the underlying VBA code.

any ideas?
Ward
 
P

Perry

Malusage of ActiveDocument versus ThisDocument might be bugging you
would be my first guess.

Are you able to kick in some VBA code?
This would be helpfull to verify my above assumption
or to see whether something else is bugging you.

Krgrds,
Perry
 
W

ward

-----Original Message-----
Malusage of ActiveDocument versus ThisDocument might be bugging you
would be my first guess.

Are you able to kick in some VBA code?

Nop, no code to show at the moment. But the last time I
had this problem (this afternoon), the template containing
the VBA code has only WordBasic commands in it (it's an
old template). Not containing any activedocument or
ThisDocument objects.

However, I had this problem in templates in which I use
not a single WordBasic command.

BTW: I always use ActiveDocument, and never ThisDocument.
Ward
 
J

Jezebel

At a guess, your code creates and retains a variable reference to the
document or some part of it (eg Set X = Selection.Range). If you're using
WordBasic this might be an implicit reference (which will make it hard to
track down); if VBA look for a module-level or global object variable.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top