ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Password protected workbooks (https://www.excelbanter.com/excel-discussion-misc-queries/60658-password-protected-workbooks.html)

Mike Stanley

Password protected workbooks
 
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

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


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com