You can break Excel file protection with VBA by
systematically testing combinations of a selected
character set against the password; i.e. the "brute force"
method. However, this is only feasible if the character
set is very limited, say, 25 characters (preferably less)
and the password is limited to a maximum of six
characters. Otherwise, it takes far too long (read
thousands of hours!!!).
In my case, I typically use lower case alphabetic
characters and may combine numerics but this is almost
invariably limited to either 1 or 2 (e.g. "monkey1"
and "monkey2"). When I consider all the letters of the
alphabet individually, I am confident that I have never
used a password that included the letters j, q, v, x and
z. Therefore, in my case, I can limit the character set
to 23. That makes it feasible for me to use this method
so long as I havn't used seven characters. Note
that "monkey2" is seven characters. I would likely be SOL
in this case (see Note).
My understanding is that the number of possible
combinations is the number of characters in the set taken
to the power of the number of characters in the password.
This exponential curve becomes damn near vertical in a
hurry.
Based on a brief test of my own system (2.4 ghz), I can
test approx. 900,000 combinations per hour. Therefore,
doing the math, I derived the following time estimates for
a 25 character set:
4 character password: 1 to 26 minutes
5 character: 26 minutes to 10.8 hours
6 character: 10.8 to 271 hours
7 character: 271 to 6782 hours
8 character: 6782 to 169542 hours
I created a macro to do this some time ago. I rigged it
to accept a specified run time after which it would store
the progress allowing you to resume at a later date.
Note: If you are able to move to the front of the list
characters that are more likely to represent the first
character of the password then you improve the odds of
reducing the time required to the lower limit.
Regards,
Greg
(VBA amateur)