Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I have a workbook with links in it. The links go to protected workbooks and I have ued the following code (posted in an earlier post 21/05/07 by Dave Peterson - thanks Dave!) which works fine if I put it in a seperate book: Sub UpdatingSheets() Dim myFileNames As Variant Dim myPasswords As Variant Dim iCtr As Long Dim myRealWkbk As Workbook Dim myRealWkbkName As String Dim wkbk As Workbook myRealWkbkName = "C:\Documents and Settings\abus9580\Desktop\Main.xls" myFileNames = Array("C:\Documents and Settings\abus9580\Desktop\Addresses1.xls", "C:\Documents and Settings\abus9580\Desktop\Ages.xls") myPasswords = Array("test", "test") If UBound(myFileNames) < UBound(myPasswords) Then MsgBox "check names & passwords--qty mismatch!" Exit Sub End If Set myRealWkbk = Workbooks.Open(Filename:=myRealWkbkName, UpdateLinks:=0) For iCtr = LBound(myFileNames) To UBound(myFileNames) Set wkbk = Nothing On Error Resume Next Set wkbk = Workbooks.Open(Filename:=myFileNames(iCtr), _ Password:=myPasswords(iCtr)) On Error GoTo 0 If wkbk Is Nothing Then MsgBox "Check file: " & myFileNames(iCtr) Exit Sub End If wkbk.Close savechanges:=False Next iCtr End Sub My question is, how do I use it in the Main workbook because it doesn't seem to work? Any help greatly appreciated. Andy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all. Please ignore as I have fixed it now.
"ajayb" wrote: Hi all, I have a workbook with links in it. The links go to protected workbooks and I have ued the following code (posted in an earlier post 21/05/07 by Dave Peterson - thanks Dave!) which works fine if I put it in a seperate book: Sub UpdatingSheets() Dim myFileNames As Variant Dim myPasswords As Variant Dim iCtr As Long Dim myRealWkbk As Workbook Dim myRealWkbkName As String Dim wkbk As Workbook myRealWkbkName = "C:\Documents and Settings\abus9580\Desktop\Main.xls" myFileNames = Array("C:\Documents and Settings\abus9580\Desktop\Addresses1.xls", "C:\Documents and Settings\abus9580\Desktop\Ages.xls") myPasswords = Array("test", "test") If UBound(myFileNames) < UBound(myPasswords) Then MsgBox "check names & passwords--qty mismatch!" Exit Sub End If Set myRealWkbk = Workbooks.Open(Filename:=myRealWkbkName, UpdateLinks:=0) For iCtr = LBound(myFileNames) To UBound(myFileNames) Set wkbk = Nothing On Error Resume Next Set wkbk = Workbooks.Open(Filename:=myFileNames(iCtr), _ Password:=myPasswords(iCtr)) On Error GoTo 0 If wkbk Is Nothing Then MsgBox "Check file: " & myFileNames(iCtr) Exit Sub End If wkbk.Close savechanges:=False Next iCtr End Sub My question is, how do I use it in the Main workbook because it doesn't seem to work? Any help greatly appreciated. Andy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Updating links in protected workbooks | Excel Discussion (Misc queries) | |||
Updating a master workbook with 80 workbooks | Excel Discussion (Misc queries) | |||
Updating Workbooks from multiple links Workbooks | Excel Worksheet Functions | |||
Updating Links in a Protected Sheets | Excel Discussion (Misc queries) | |||
Group, Outline, Protected Worksheets and Protected Workbook | Excel Programming |