Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Links in Excel 1

Status
Not open for further replies.

JoBlink

Technical User
May 28, 2004
38
US
hi!

I have a workbook with several links to DDE server.

The link source is an external file on a server to which I have no direct access, and updates come automatically at random intervals.

I would like to know if there is a way to write the code that will show me a message box every time a link is updated.
Are there any distinguishable properties to those links?

ideally I want to work like this: message box "link two in cell B1 updated", message box "link one cell A1 updated", message box "link three in cell C1 updated".

I have a code that responds to any link update
--------------------------------------------------
Sub linktest()

'ActiveWorkbook.SetLinkOnData (MsgBox("Update"))
'Sub LinkList()
Dim Links As Variant
' Obtain an array for the links to Excel workbooks
' in the active workbook.

Links = ActiveWorkbook.LinkSources(xlOLELinks)

' If the Links array is not empty, then open each
' linked workbook. If the array is empty, then
' display an error message. In this case, UBOUND(Links) =3, ' that is how many links I created in a workbook
If Not IsEmpty(Links) Then
For i = 1 To UBound(Links)
'MsgBox ("link found")
ActiveWorkbook.SetLinkOnData Links(i), "RunMyCustomSub"

Next i
Else
MsgBox "This workbook does not contain any links " & _
"to other workbooks"
End If
 
Create three sub, say RunMyCustomSub1, ..., RunMyCustomSub3
Then replace this:
ActiveWorkbook.SetLinkOnData Links(i), "RunMyCustomSub"
By this:
ActiveWorkbook.SetLinkOnData Links(i), "RunMyCustomSub" & i
Now, each sub knows which link is updated.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top