File Duplicated in VBE Explorer Pane

J

JMay

Just playing around to be warned if a file has been altered in any way (dirty).
Somehow if before closing I switch to the VBE envirnoment - I see 2
representions of the file complete with sheet1, sheet2, sheet3, thisworkbook
and module1

In module1 I only have

Public mFlag

I'm probably violating some rule causing this - can someone comment on this?
TIA

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If mFlag = True Then
MsgBox "You have altered your file"
Else
MsgBox "You have NOT altered your file"
End If
End Sub


Private Sub Workbook_Open()
Dim mFlag As Boolean
mFlag = False
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
mFlag = True
End Sub
 
G

Gord Dibben

Place the code into Thisworkbook module.

Those type of events don't fire from a general module.


Gord Dibben MS Excel MVP
 
J

JMay

Thanks Gord, but note that these 3 ARE in the THISWORKBOOK Module
"Private Sub Workbook"

I created Module1 to house the one-liner:
Public mFlag '<<to make its value visible/In Scope...
 
G

Gord Dibben

Mis-interpreted your original.

What you're saying is it looks like the file has two instances loaded?

I don't know what causes this effect.

Happens to me on occasion but no ideas.


Gord
 
J

JMay

Yeah - like you say, it looks like two instances are loaded.
Oh Well, Much obliged for taking the time to look and comment,
Jim
 
D

Dave Peterson

Just to add to what Gord wrote...

If you're careful--don't work with those projects, then it shouldn't be a
problem. If you work with those ghost projects, you'll be wasting your time.

If it really bothers you, close excel and restart it. That's the only way I've
seen that removes the ghost projects.
 

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