forcing refresh links
The final solution:
Private Sub Workbook_Activate()
aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)
If Not IsEmpty(aLinks) Then
For i = 1 To UBound(aLinks)
' MsgBox "Link " & i & ":" & Chr(13) & aLinks(i)
backslpoz = InStrRev(aLinks(i), "\")
linkwbnev = Mid(aLinks(i), backslpoz + 1)
If Not IsOpenWB(linkwbnev) Then
ThisWorkbook.UpdateLink Name:=linkwbnev, Type:=xlExcelLinks
End If
Next i
End If
End Sub
Public Function IsOpenWB(ByVal munkafuzet As String) As Boolean
'returns true if workbook is open
Dim objWorkbook As Object
On Error Resume Next
IsOpenWB = False
Set objWorkbook = Workbooks(munkafuzet)
If Err = 0 Then IsOpenWB = True
End Function
Stefi
€˛Stefi€¯ ezt Ć*rta:
My solution is not complete! It works only if linked workbooks are ALL
closed! Any idea how to handle the case when some of them are just open?
Stefi
€˛Stefi€¯ ezt Ć*rta:
Hi Dave,
You won! Creating an event that keeps looking for closing workbooks seems a
bit complicated. But anyway, many thanks, because you put me in the right
direction:
Private Sub Workbook_Activate()
ActiveWorkbook.UpdateLink Name:= _
ActiveWorkbook.LinkSources, _
Type:=xlExcelLinks
End Sub
of WB A does the trick, because WB B must be the active workbook when I
close it, and having it closed WB A becomes the active workbook, either
automatically or clicking on it. It's satisfactory to have WB A refreshed
when it becomes active next time.
Regards,
Stefi
€˛Stefi€¯ ezt Ć*rta:
€˛Dave Peterson€¯ ezt Ć*rta:
You could always use:
Edit|links|Update values
But I bet you're looking for something more automatic.
Maybe you could have some application event that looks for a workbook that's
closing and then cycles through all the other workbooks and does that same
function.
I don't see anything that's built into excel that would do this automatically.
Stefi wrote:
Hi All,
I have a link in WB A to WB B. When I change the source cell in WB B (it
contains a Boolean value) from FALSE to TRUE, link is refreshed in WB A. But
when I close WB B without saving (keeping the unchanged source value FALSE),
link in WB A is refreshed only when I reopen WB A. My question is that can I
somehow force refreshing link immediately when I close WB B without saving?
Thanks,
Stefi
--
Dave Peterson
|