Leading the way in Microsoft Office Development
 Home|Excel|Word|PowerPoint|Consultancy|Feedback|Contact 
 Microsoft Excel > Macros > Projects And Passwords< Previous | Next > 

 

BUG - VBA Projects Still Visible

 
 

When you open a workbook that contains macros (i.e. a VBA Project) this project can remain visible in the Visual Basic Editor after the workbook has been closed.

 
   
 

To try and recreate this problem, perform the following:

 
 

1) Open Excel and create a new blank workbook.

 
 

2) Press (Alt + F11) to display the Visual Basic Editor.

 
 

3) Insert a module (not a class module) into this project.

 
 

4) Create a new subroutine as follows:

 
 
1
2
Sub Testing()
End Sub
   
 

5) Save the workbook (e.g. C:\Temp\Book1.xls).

 
 

6) Close the workbook.

 
 

7) The VBA project Book1.xls remains visible in the Visual Basic Editor Project window.

 

 

BUG - Duplicate VBA Projects

 
 

If you open the workbook again another VBA Project is created in the Project window.

 
 

If you close and re-open the workbook again yet another VBA Project will be created in the Project window.

 
   

 

BUG - Prompting for Password

 
 

If you use VBA code and the VBA Project associated with that workbook or add-in has a password then you may be prompted for a password when you close Excel.

 
 

Pressing cancel will either close this dialog box after several attempts or it will be displayed indefinitely (resulting in a Task Manager > End Process).

 
   
 

To try and recreate this problem, perform the following:

 
 

8) Open Excel and create a new blank workbook.

 
 

9) Select (View > Toolbars > Control Toolbox) to display this toolbar.

 
 

10) Add a command button to a worksheet.

 
   
 

11) Double click this command button and add the following line of code to the Click Event Handler:

 
 
3
4
5
Private Sub CommandButton1_Click()
   Call Testing
End Sub
   
 

12) Insert a Userform into this project.

 
 

13) Insert a module (not a class module) into this project.

 
 

14) Create a new subroutine as follows:

 
 
6
7
8
9
Sub Testing()
   Load Userform1
   Userform1.Show
End Sub
   
 

15) Exit Design View and press the button to make sure that the userform is displayed.

 
   
 

16) You can close the userform using the cross in the top right hand corner.

 
 

17) Add a password to the project.

 
 

18) Return to the Visual Basic Editor and select (Tools > VBA Project Properties) and select the Protection tab.

 
 

19) Select "Lock project for viewing" and enter the password "aa".

 
 

20) Confirm the password and press OK.

 
 

21) Save the workbook (e.g. C:\Temp\Book2.xls).

 
 

22) Close Excel.

 
 

23) Open Excel and open the workbook you just saved (e.g. C:\Temp\Book2.xls).

 
 

24) Press the button and make sure that the userform is displayed.

 
 

25) Close Excel using (File > Exit) (do not close the workbook first).

 
 

26) The VBA Project Password dialog will be displayed if you have a COM Add-in installed that is loaded with mscoree.dll.

 

 

Solution

 
 

Uninstall any COM Add-ins that you are currently using.

 
 

The most obvious one is the Google Desktop.

 
 

You can uninstall this add-in using the (Control Panel > Add or Remove Programs).

 
 

You can check which add-ins are installed by looking at the following registry entry:

 
 
10
HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\
   

 Copyright © 2004-2007 Better Solutions Limited. All Rights Reserved.< Previous | Top | Next >