Thread: Links
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Links

It looks like you could cycle through all the links looking for "weekly report"
(or even more??).

I stole the code from VBA's help and modified it to go through all the links:

Option Explicit
Sub testme02()

Dim astrLinks As Variant
Dim iCtr As Long

astrLinks = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLi nks)

If IsArray(astrLinks) Then
For iCtr = LBound(astrLinks) To UBound(astrLinks)
If InStr(1, astrLinks(iCtr), "weekly report", _
vbTextCompare) 0 Then
'do the change
End If
Next iCtr
End If

End Sub



gwhenning wrote:

I have a series of weekly financial reports that are always named like this
"Weekly report Week "&<WeekNo.&".xls" I've written a macro on a summary
document that prompts the user to select the week they want to summarize and
change the link to reference the new week. I change the link using the
ActiveWorkbook.ChangeLink Name:="X:\Weekly report Week 01.xls",
NewName:=NewLinkName, Type:=xlExcelLinks method. The problem is that when the
user opens the .xlt file and selects a week everything works normally but if
they change the week and then change it again the code breaks because there
is now no link named "X:\Weekly report Week 01.xls" How can you get a list of
the links in an excel file without using an add-on?


--

Dave Peterson