Home |
Search |
Today's Posts |
#1
|
|||
|
|||
General purpose "open links" macro
Is it possible to write a macro which will open all linked workbooks
without hard coding the workbook names so as to make such a macro more general? Thanks |
#2
|
|||
|
|||
When you say 'all linked workbooks', do you mean all workbooks directly
linked to the current workbook, or every workbook in every link in every workbook that is opened by the routine, ie if book a is linked to b, and b to c and c to d and d to e etc, then by running the routine from a, you would open b, c, d, e? If you just want to open all workbooks with references in 'Edit Links' within your activeworkbook, then how about:- Sub OpenAllLinks() Dim CurWkbk As Workbook Dim arLinks As Variant Dim intIndex As Integer Set CurWkbk = ActiveWorkbook arLinks = CurWkbk.LinkSources(xlExcelLinks) If Not IsEmpty(arLinks) Then For intIndex = LBound(arLinks) To UBound(arLinks) CurWkbk.OpenLinks arLinks(intIndex) Next intIndex Else MsgBox "The active workbook contains no external links." End If End Sub Slight tweak on example straight out of help. -- Regards Ken....................... Microsoft MVP - Excel Sys Spec - Win XP Pro / XL 97/00/02/03 ------------------------------*------------------------------*---------------- It's easier to beg forgiveness than ask permission :-) ------------------------------*------------------------------*---------------- "noyb" wrote in message ... Is it possible to write a macro which will open all linked workbooks without hard coding the workbook names so as to make such a macro more general? Thanks |
#3
|
|||
|
|||
Works great, thanks
Ken Wright wrote: When you say 'all linked workbooks', do you mean all workbooks directly linked to the current workbook, or every workbook in every link in every workbook that is opened by the routine, ie if book a is linked to b, and b to c and c to d and d to e etc, then by running the routine from a, you would open b, c, d, e? If you just want to open all workbooks with references in 'Edit Links' within your activeworkbook, then how about:- Sub OpenAllLinks() Dim CurWkbk As Workbook Dim arLinks As Variant Dim intIndex As Integer Set CurWkbk = ActiveWorkbook arLinks = CurWkbk.LinkSources(xlExcelLinks) If Not IsEmpty(arLinks) Then For intIndex = LBound(arLinks) To UBound(arLinks) CurWkbk.OpenLinks arLinks(intIndex) Next intIndex Else MsgBox "The active workbook contains no external links." End If End Sub Slight tweak on example straight out of help. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
** Links don't update UNLESS source file is open | Links and Linking in Excel | |||
** Links don't update UNLESS source file is open | Links and Linking in Excel | |||
Button fails to call macro when open an Excel via Intranet | Excel Discussion (Misc queries) | |||
Open Word Doc From Excel Macro | Excel Discussion (Misc queries) | |||
How do I get my personal macro worksheet to open whenever I open . | Excel Discussion (Misc queries) |