Excel file asks for VBA password when trying to close it

Dave L

Board Regular
Joined
Jun 19, 2003
Messages
87
A client is using an Excel file that we created that contains some VBA code. He enables macros when it opens and everything works fine. However, when he tries to close the file, it asks for a VBAProject password. The only Workbook_BeforeClose event is shown below.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

Saving has been disabled in the workbook and this just tells the workbook to close without asking about saving even if it has been modified.

We have tested this same file in two different versions of Excel and we don't get the message when we close it. Does anyone have an idea of what might cause this?

Thanks,

Dave
 

pfarmer

Well-known Member
Joined
Jul 6, 2005
Messages
550
Dave L said:
A client is using an Excel file that we created that contains some VBA code. He enables macros when it opens and everything works fine. However, when he tries to close the file, it asks for a VBAProject password. The only Workbook_BeforeClose event is shown below.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub

Saving has been disabled in the workbook and this just tells the workbook to close without asking about saving even if it has been modified.

We have tested this same file in two different versions of Excel and we don't get the message when we close it. Does anyone have an idea of what might cause this?

Thanks,

Dave
Does it get this with any other workbook that uses Macros?

Perry
 

Dave L

Board Regular
Joined
Jun 19, 2003
Messages
87
pfarmer,

He has some other files from us that are a similar type and they all work fine. That is what has us so puzzled.

Dave
 

pfarmer

Well-known Member
Joined
Jul 6, 2005
Messages
550
Dave L said:
pfarmer,

He has some other files from us that are a similar type and they all work fine. That is what has us so puzzled.

Dave
To me it sounds like you have an addin located in the sheet.

Does it ask for the password before or after the sheet appears to be closed?

Perry
 

Dave L

Board Regular
Joined
Jun 19, 2003
Messages
87
pfarmer,

I'm not sure if the sheet appears to close before he gets the message. I will have to contact him to find out.

The workbook does use the analysis toolpak addin. Why would an addin cause this behavior?

Thanks,

Dave
 

pfarmer

Well-known Member
Joined
Jul 6, 2005
Messages
550
Dave L said:
pfarmer,

I'm not sure if the sheet appears to close before he gets the message. I will have to contact him to find out.

The workbook does use the analysis toolpak addin. Why would an addin cause this behavior?

Thanks,

Dave
I doubt that the analysis toolpak would be causing this problem since the user would probably get errors if he was trying to use functions on the sheet that required it. I was thinking along the lines that the sheet was referencing a resource present on your machines which he doesn't have access to.

From reading another post if an addin was causing a problem, something to try is:

remove the password and save the add-in
close Excel
start excel and give the add-in a password and save it
close Excel

Since the analysis toolpak is protected then you can not remove the password.

However maybe one could delete the analysis toolpak, then reinstall it just in case this would simulate the above.

Perry
 

gplhl

Board Regular
Joined
Feb 23, 2002
Messages
148
Did anyone get to the bottom of this, I am having exactly the same problem, I also have code saving the workbook on exit. The other exasperating thing is it doesnt happen on my PC but it does my bosses?
 

Forum statistics

Threads
1,078,249
Messages
5,339,081
Members
399,276
Latest member
Donjayok

Some videos you may like

This Week's Hot Topics

Top