+ Reply to Thread
Results 1 to 19 of 19

Asks for password for protected VBA code when closing Excel

  1. #1
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Exclamation Asks for password for protected VBA code when closing Excel

    Hi, there
    I have a spreadsheet with a piece of VBA code built in at "ThisWorkbook" as below:
    Please Login or Register  to view this content.
    Additionally, there are some forms with built in VBA codes. All the VBA codes are protected with the same password. Here is the problem, after close this speadsheet, if it is attempted to close Excel after it, a message comes out and asks for password for the VBA code. A several methods were tried to get rid of this problem. It seems it only works if do the following step

    Close the spreadsheet
    Open Microsoft Visual basic editor
    Highlight the VBA project of the speadsheet
    Close Microsoft Visual basic editor
    Close Excel.

    Does anybody have even met this problem before? How can I solve it without going through the step listed above?

    Thanks in advance. Your time and effort will be highly appreciate.

    Best regards,
    Chunli
    Last edited by romperstomper; 09-13-2010 at 09:23 AM. Reason: add code tags.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Asks for password for protected VBA code when closing Excel

    Do you have any COM addins such as Google Desktop installed? That has been known to cause that problem.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Asks for password for protected VBA code when closing Excel

    Yeah. I think it might be some COM addins installed in my PC, since I have no admin right to the PC I am using now, it seems difficult to check.

    Is there a way get around it?

    Thanks.

    Regards,
    Chunli

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Asks for password for protected VBA code when closing Excel

    Not without either uninstalling them or editing the registry to alter their loadbehavior property generally.
    If you fire up the COM add-ins dialog, what do you have there?

  5. #5
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Asks for password for protected VBA code when closing Excel

    I have: Analysis ToolPak, Analysis ToolPak - VBA, Conditional sum wizard, Euro CUrrency tools, Internet assitant VBA, Lookup Wizard, Solver Add-in. But none of it is turned on.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Asks for password for protected VBA code when closing Excel

    That's the Addins dialog, not the COM addins dialog. Run this code:
    Please Login or Register  to view this content.
    and tell me what's listed in the dialog.

  7. #7
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Asks for password for protected VBA code when closing Excel

    Am supposed to run in Microsoft Visual editor? I tried, there is an error message: "Run-time error 91" Object variable or with block variable not set

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Asks for password for protected VBA code when closing Excel

    Oops - should have figured that only works when you already have the button on a toolbar somewhere. Choose View-Toolbars-Customize..., then select the Commands tab, choose Tools from the left list, then about half way down the right list, select the 'COM add-ins...' button and drag it onto a toolbar. Now close the dialog and click the button you added to the menu.

  9. #9
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Asks for password for protected VBA code when closing Excel

    Hi, I did as you suggested. The result is shown in a screen shot in attached word file. Thanks.
    Attached Files Attached Files

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Asks for password for protected VBA code when closing Excel

    You couldn't just have said there was nothing in the list?
    It would seem that if you do have any COM addins they are installed for all users (those don't appear in that dialog) in which case there is probably nothing you can do about it. I suggest you talk to your IT department.

  11. #11
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Asks for password for protected VBA code when closing Excel

    Hi, there
    Asked IT already long time ago. They could not do anything about it. Could you please suggest anything I can do to fix it. Either is there anyway get around it? Thanks.

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Asks for password for protected VBA code when closing Excel

    Have a look at this DDoE posting. Essentially, you need to alter the LoadBehavior of each COM addin to 2.

  13. #13
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Asks for password for protected VBA code when closing Excel

    Thanks. It's working when I change the following HKEY to 2 ( Default 3).

    HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins\Office.Desktop.Google.com\LoadBehavior

    Considering using 2 might change the behavior of the addins, I followed the suggestion from Andrew and tried the code below:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    If Not (Application.VBE.MainWindow.Visible) Then
    Application.VBE.MainWindow.Visible = True
    Application.VBE.MainWindow.Visible = False
    End If
    End Sub

    But Excel gives me an error message of 1004 and "Programmatic access to Visual Basic Project is not trusted".

    Any suggestions?
    Last edited by SpringLily; 09-14-2010 at 03:55 AM.

  14. #14
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Asks for password for protected VBA code when closing Excel

    Perhaps this link will be of help.

    http://support.microsoft.com/kb/282830

  15. #15
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Asks for password for protected VBA code when closing Excel

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  16. #16
    Registered User
    Join Date
    09-13-2010
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: Asks for password for protected VBA code when closing Excel

    Thanks. It works. However, the code I used doesn't cure the problem in this thread. Excel still asks for password while closing.

  17. #17
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Asks for password for protected VBA code when closing Excel

    Try removing google desktop to see if that helps, or if there's another addin causing the problem.

  18. #18
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Asks for password for protected VBA code when closing Excel

    You could try this:

    Click "Start" -> "Run" type "msconfig" and look at tabs "Startup" and "Services"

    Check if you got anything "unursual" running, i.e. not related to Microsoft or any program you know you are running.

    You could also take a look in "Windows Task Manager" tab "Processes"

    Alf

  19. #19
    Registered User
    Join Date
    11-06-2007
    Posts
    28

    Re: Asks for password for protected VBA code when closing Excel

    Any solution to this issue, SIX YEARS later?
    I can't find a solution nowhere!
    My customer sees the password dialog box on the excel file I sent him... but i DON'T see any dialog box on my computer using same file!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1