link password protected files

proctk

Well-known Member
Joined
Dec 24, 2004
Messages
840
Hi

I'm working at linking 30 spreadsheets one sheet that combines the results from them. The problem I'm having is each workbook is password protected and it prompts me to enter the password for each spreadsheet each time I open the master sheet. Is there a way I can stop this. The good news is every workbook as the same password. Maybe some type of macro

Any help is excellent.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I found this code by seaching google.

I'm thinking I could use something like this but get it to loop through and open all the files in the folder that is linked to the master page

Code:
Sub TestPassword()
         'Open the workbook with the password (Test2.xls) first and supply
         'the password with the password argument.
         Workbooks.Open filename:="Test2.xls", updateLinks:=3, _
            password:="test"
         'When Test1.xls is opened, the links are updated automatically.
         Workbooks.Open filename:="Test1.xls", updateLinks:=3
         'Becuase Test2.xls is open, you can close Test2.xls.
         Workbooks("Test2.xls").Close
      End Sub
 
Upvote 0
I guess you could use a hook for this specially that the password is the same for opening all the workbooks. )- It will be rather involced but if you think it will really help you with the (30 linked workbooks ! ) I can put up some code for you .

Regards.
 
Upvote 0
That would be great, my issue is when I go to update the information it askes me to enter the password 30 times.

The password will always be the same for all 30 files.

thank you
 
Upvote 0
I also thought of runninga macro to open all the files first, then open update the links. after. this is what I have but does not work

Code:
Sub Open_Work_books()
Dim wbNew As Workbook
Dim WkbkName As Object
Dim ws As Worksheet
Dim strPath$
    With Application
        .ScreenUpdating = False
        .DisplayAlerts = False
        .EnableEvents = False
        strPath = ThisWorkbook.Path & "\"
        
        For Each WkbkName In Application.Workbooks()
            'ws.Copy
         
            With wbNew
               Workbooks.Open Filename:=strPath & ws.Name & ".xls", Password:="12345"
                
            End With
            
        Next WkbkName
        
        .EnableEvents = True
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With
End Sub
 
Upvote 0
Hi,

Before making this more difficult than it is necessary. Why not provide the WriteResPassword parameter as well when opening the linked workbooks as follows : - it worked for me.

Note this assumes that all the 30 files are located in the same folder as that of the master file and that there are no other more workbooks in the folder apart from the 30 we are trying to open.

Code:
Sub Test()
 
    Const PASSWORD As String = "12345"
    
    Dim strPath As String
    Dim strNextFile As String
    
    strPath = ThisWorkbook.Path & "\"
    
    
    strNextFile = Dir(strPath, vbNormal)
    
    On Error Resume Next
    Application.ScreenUpdating = False
    
    Do While Len(strNextFile) <> 0
        
        If strNextFile <> ThisWorkbook.Name Then
            If Right(strNextFile, 4) = ".xls" Then
                Workbooks.Open Filename:=strPath & strNextFile, _
                UpdateLinks:=xlUpdateLinksAlways, _
                PASSWORD:=PASSWORD, WriteResPassword:=PASSWORD
            End If
        End If
        
        strNextFile = Dir
    Loop
    
    Application.ScreenUpdating = True
 
End Sub

Regards.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top