Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Aug 2002
    Thanked 0 Times in 0 Posts

    Disabling passwords/Custom Save As command (VBA/Word XP and Excel XP)

    To all,

    Recently, a small businessman asked me to disable password protection for Word XP and Excel XP in his computer. Apparently, his employees have been setting passwords on Word and Excel files without his knowledge, and obviously if they leave his company and don't tell him the password(s), he'll be in a real bind.

    Luckily, I found the following KB article which describes how to disable passwords in Word XP and Excel XP:;EN-US;Q309312. However, att the end of the article, it says, "users can still set passwords for a file by using the Save As command..."

    Okay, no problem. To get around this, I've programmed my own CustomFileSaveAs VBA procedures which replace the built-in Word and Excel Save As commands. My CustomFileSaveAs procedures simply call a form with the Common Dialog Control's stripped-down Save As dialog. This simplified Save As dialog allows no way for the user to set a password, so that's great. I've also programmed my own CustomFileSave, CustomFileClose and CustomFileExit procedures for both Word and Excel -- these procedures call my CustomFileSaveAs procedure when necessary. In addition, I've replaced the File menu entries for the SaveAs, Save, Close and Exit commands in both Word and Excel with my custom ones. I've also trapped all relevant keyboard shortcuts (Ctrl-S, Alt-F4) and replaced the Save command in Word and Excel's Standard toolbar. All my code and customizations reside in a .dot and .xla AddIn for Word and Excel, respectively.

    Now, here are my problems (and I've already discussed them with one member of this Lounge, Gary Frieder):

    1. In both Word and Excel, how do I trap the user closing the file or application via the "x" in the window's upper right corner? (I have trapped all menu items, keyboard shortcuts, toolbars, but not this!) If they close a file or the application this way, they will get the built-in Word or Excel Close or Exit commands instead of my CustomFileClose and CustomFileExit commands.

    2. Can I prevent the user from messing with my menu assignments? This is more of a problem in Excel than Word. In Word, the user would actually have to remove my .dot attachment to restore the default menus, but in Excel, all he'd have to do is go to Tools | Customize, point the "Worksheet Menu Bar" and click Reset.

    (Both these problems I'm certain must have been addressed and probably solved by programmers for Document Management Systems like Docs Open and iManage who create AddIns for Word and Excel. They too trap Word and Excel's default SaveAs, Save, Close and Exit commands in these AddIns.)

    3. Lastly, the businessman is concerned that his employees may not give him the password(s). I told him there is no way a Word or Excel file can be opened if you don't know its password. Am I wrong? Can a Word or Excel file's password be cracked?

    Thanks for any feedback,


  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Silicon Valley, USA
    Thanked 94 Times in 90 Posts

    Re: Disabling passwords/Custom Save As command (VBA/Word XP and Excel XP)

    1. The X button is a problem for everyone. The DMS' often work by monitoring Windows calls and intercepting the dialogs at the system level. This is not practical for your application.

    2. You can intercept commands by setting up an event sink for a CommandBarControl.Id. There should be code samples on this board.

    3. I read on Sun's site that pre-release versions of StarOffice 6.0 (maybe betas?) would open Word files regardless of whether they were protected with a password. Might want to go find a copy somewhere. There are some "brute force" cracking programs, but for long passwords, the time required may be prohibitive.

    I think the real issue is, what's with these people? If there's no trust and sense of team spirit in the workplace, you can't program around that. The business is doomed. Make sure you get paid in advance.

Posting Permissions

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