ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   DDE link update for stock quotes (https://www.excelbanter.com/excel-programming/275451-dde-link-update-stock-quotes.html)

[email protected]

DDE link update for stock quotes
 
Hello,

I have a spreadsheet that uses DDE links to retrieve stock quotes. I
have set all of the links to use auto updating. For some unknown
reason, 1 or more DDE link will be reset to manual updating. (I
haven't been able to determine what causes this.)

I have some VBA code to get a list of the DDE links in the workbook,
and determine which one(s) are set to manual. I use the following:

Public Sub TestLinks()
Dim aLinks As Variant
Dim i As Integer

On Error GoTo ErrorHandler

aLinks = ActiveWorkbook.LinkSources(xlOLELinks)
If Not IsEmpty(aLinks) Then
For i = 1 To UBound(aLinks)
If ActiveWorkbook.LinkInfo(aLinks(i), xlUpdateState,
xlLinkInfoOLELinks) = 2 Then
Debug.Print "manual link:" & aLinks(i)
End If
Next i
End If

ExitProcedu
On Error Resume Next

Exit Sub
ErrorHandler:
MsgBox Err.Description, vbCritical + vbOKOnly
Resume ExitProcedure
End Sub

I'm aware that I can go to the Edit-Links menu, and change the link
update there. My question is this: is there a way to
programmatically change a link from manual update to auto update?
(Setting the LinkInfo property to 2 doesn't seem to work.)

Thanks,

Mike


All times are GMT +1. The time now is 12:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com