PDA

View Full Version : Open and Delete all VBA Components -- on locked Files



asingh
11-10-2010, 07:24 PM
THIS IS NOT A HACK REQUEST

Hi,

I have a bunch of files which I need to open, do some formatting, delete out the VBA content and save. I have put in the following..

1. Open file.
2. Process.
3. Save and Close.

Now IF the files VBA project is locked (password protected) and I do know the password, what code can be used to supply the password and unlock the project delete the contents, and lock the project back. I need to lock the project back, since some tabs are xlveryhidden.

I did search the www, and mostly found sendkeys methods, even that was not working.

I also have working code which deletes out the VBA content but fails if the project is locked/password protected for 'viewing'.

Help would be great....! Thanks...!

Anil

Bob Phillips
11-11-2010, 12:54 AM
The SendKeys method, whilst wholly unreliable, is the only method I know of.

Jan Karel Pieterse
11-11-2010, 05:03 AM
What Excel version are we talking about? Saving files without VBA project is very simple in 2007... EVen if you're on 2003, you could consider doing a save-as to xlsx, close and open the xlsx and then save-as back to 2003 format. The end result being a file with no VBA.

asingh
11-19-2010, 11:19 PM
^^
Will try this, and post back. Thanks.