Password protected workbooks
Create the 11th workbook that opens the first 9 (supplying the password) and
then opens the master.
Is it ok to open those other workbooks?
Option Explicit
Sub testme()
Dim myFileNames As Variant
Dim myPWDs As Variant
Dim iCtr As Long
Dim testStr As String
'put all ten workbook names here
'end with the master workbook name
myFileNames = Array("C:\my documents\excel\book1.xls", _
"C:\my documents\excel\book2.xls", _
"C:\my documents\excel\master.xls")
'same with the passwords
myPWDs = Array("pwd1", _
"pwd2", _
"")
If UBound(myFileNames) < UBound(myPWDs) Then
MsgBox "design error!"
Exit Sub
End If
For iCtr = LBound(myFileNames) To UBound(myFileNames)
On Error Resume Next
Workbooks.Open Filename:=myFileNames(iCtr), Password:=myPWDs(iCtr)
If Err.Number < 0 Then
MsgBox myFileNames(iCtr) & " didn't open" & vbLf & "Quitting!"
Err.Clear
Exit Sub
End If
Next iCtr
End Sub
Mike Stanley wrote:
I have one master workbook that has sheets that are linked to 9 other
workbooks. The other 9 workbooks have individual passwords. When I open the
"master" workbook, I have to enter the other 9 workbook passwords. How do I
get around that? Anybody?
--
M.Stanley
--
Dave Peterson
|