Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel,microsoft.public.excel.links,microsoft.public.excel.misc,microsoft.public.excel.newusers,microsoft.public.excel.programming,microsoft.public.excel.setup,microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I have the following code that should open all EXCEL workbooks in a
specified path, and unprotoect any password-protected worksheets to allow for Link Updates, then close the workbook after password protecting it. For some reason, I can't get this code to work -- any ideas? ================================ I put the following code in a general module of a sheet1 of a workbook sub UpdateAllLinks() Dim vLinkSources Dim iLinkSource As Integer Dim AnySheet As Worksheet sPath = " C:\Documents and Settings\Shane\My Documents\Harcourt Assessments\password" sName = Dir(sPath & "*.xls") do while sName < "" set bk = Workbook.Open(sPath & sName) For Each AnySheet In ActiveWorkbook.Worksheets ActiveWorkbook.Worksheets(AnySheet.Name) _ .Unprotect Password:="mypassword" Next vLinkSources = ActiveWorkbook.LinkSources(xlExcelLinks) If Not IsEmpty(vLinkSources) Then For iLinkSource = LBound(vLinkSources) To UBound(vLinkSources) ActiveWorkbook.UpdateLink _ vLinkSources(iLinkSource), xlExcelLinks Next End If For Each AnySheet In ActiveWorkbook.Worksheets ActiveWorkbook.Worksheets(AnySheet.Name) _ .Protect Password:="mypassword" Next bk.Close Savechanges:=True sName = Dir() Loop End Sub Then I put a command button on worksheet1 in that workbook, and added the following code. Private Sub CommandButton1_click() UpdateAllLinks End sub Thanks in advance for any assistance |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I update data in 3 related files in Excel? | Excel Discussion (Misc queries) | |||
Excel worksheets become protected out of the blue | Excel Discussion (Misc queries) | |||
How do you protect hidden linked worksheets with in an Excel workb | Excel Discussion (Misc queries) | |||
Inserting a new line when external data changes | Excel Discussion (Misc queries) | |||
Dynamically create worksheets in Excel based off existing data? | Excel Discussion (Misc queries) |