LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to clear a batch of VBA projects' passwords

Hi,my friends,
My Problem is --
There're a batch of workbooks with the same konwn vba project password.how
to clear them at one time?

The following procedure can not work.

Sub UnprtVBA()
Dim filename As Variant
Dim PassWd As Variant
Dim thisbook As Workbook

Application.DisplayAlerts = False
Application.ScreenUpdating = False

filename = Application.GetOpenFilename("Excel Files (*.xls), *.xls", ,
"MultiSelect", MultiSelect:=True)
If VarType(filename) = vbBoolean Then Exit Sub

PassWd = Application.InputBox("If you the WorkBooks are proteced by a
password, enter it below" & Chr(13) & Chr(13) & "Leave the field blank if no
password is required", AT)
If PassWd = False Then Exit Sub

For i = 1 To UBound(filename)

Set thisbook = Workbooks.Open(filename(i))

Dim vbProj As Object
Set vbProj = thisbook.VBProject
If vbProj.Protection = 1 Then
Application.SendKeys "%{F11}", True
Application.SendKeys "%T", True
Application.SendKeys "e", True
myPW = PassWd
Application.SendKeys myPW, True
Application.SendKeys "{ENTER}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "%{F11}", True
End If

Application.SendKeys "%{F11}", True
Application.SendKeys "%T", True
Application.SendKeys "e", True
myPW = PassWd
Application.SendKeys "^{TAB}", True
Application.SendKeys "{-}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{TAB}", True
Application.SendKeys "{DEL}", True
Application.SendKeys "{ENTER}", True
Application.SendKeys "%{F11}", True

thisbook.Save
thisbook.Close True
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer a name from one cell to another but leave clear if clear? Scoober Excel Worksheet Functions 3 May 22nd 09 02:55 AM
run batch job from each row - how to insert run batch function per row? Mitchell_Collen via OfficeKB.com Excel Discussion (Misc queries) 5 February 26th 09 07:16 AM
clear the clear the web page email attachment lines MCrider Excel Discussion (Misc queries) 0 November 11th 07 10:05 PM
help with projects Mike Excel Discussion (Misc queries) 0 February 10th 07 10:51 AM
How to become a better programmer, post college. More projects or less projects. Matt Somers Excel Programming 1 February 12th 04 01:54 PM


All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"