Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Updating workbook from protected workbooks...

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Updating workbook from protected workbooks...

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
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
Updating links in protected workbooks Alan P Excel Discussion (Misc queries) 1 November 3rd 09 09:15 PM
Updating a master workbook with 80 workbooks La La Lara Excel Discussion (Misc queries) 1 March 13th 08 03:09 PM
Updating Workbooks from multiple links Workbooks TimJames Excel Worksheet Functions 1 December 15th 07 03:34 PM
Updating Links in a Protected Sheets [email protected] Excel Discussion (Misc queries) 2 July 6th 07 08:34 PM
Group, Outline, Protected Worksheets and Protected Workbook BEEJAY Excel Programming 0 February 13th 06 08:40 PM


All times are GMT +1. The time now is 12:11 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"