X
xlcharlie
I am trying to create an Excel function that will use DDE Links to pull in
information from another program. The code I have so far is:
Public Function ExternalData(symb As String, fld As String)
Dim ch As Variant, code As Variant
ch = DDEInitiate(App:="ExtSys", Topic:="Quote")
code = DDEAppReturnCode
If code <> 0 Then
LiquidData = "No DDE"
Exit Function
End If
ExternalData = DDERequest (channel:=ch, item:=symb)
code = DDEAppReturnCode
If code <> 0 Then
ExternalData = "DDE Failure"
Exit Function
End If
DDETerminate Channel:=ch
End Function
I'm brand new to using DDE links in VBA so I'm not sure where I've gone
wrong, but the function results in the value "FALSE" when it should be a
numeric value. Also when I look in the Links Editor, it does not appear any
DDE Links have been established, even when I comment out the DDETerminate in
the code. I've tried replacing the DDERequest with the function that is
normall used in the spreadsheet to pull in data from the external system -
Evaluate ("=ExtSys|" & fld & "!" & symb) - but because I can't seem to
establish the DDE links, this just results in a "N/A" error. Any tips on how
I can make this work? I realize it's a difficult question to field without
knowing the system Excel is going out to.
Thanks for the help!
information from another program. The code I have so far is:
Public Function ExternalData(symb As String, fld As String)
Dim ch As Variant, code As Variant
ch = DDEInitiate(App:="ExtSys", Topic:="Quote")
code = DDEAppReturnCode
If code <> 0 Then
LiquidData = "No DDE"
Exit Function
End If
ExternalData = DDERequest (channel:=ch, item:=symb)
code = DDEAppReturnCode
If code <> 0 Then
ExternalData = "DDE Failure"
Exit Function
End If
DDETerminate Channel:=ch
End Function
I'm brand new to using DDE links in VBA so I'm not sure where I've gone
wrong, but the function results in the value "FALSE" when it should be a
numeric value. Also when I look in the Links Editor, it does not appear any
DDE Links have been established, even when I comment out the DDETerminate in
the code. I've tried replacing the DDERequest with the function that is
normall used in the spreadsheet to pull in data from the external system -
Evaluate ("=ExtSys|" & fld & "!" & symb) - but because I can't seem to
establish the DDE links, this just results in a "N/A" error. Any tips on how
I can make this work? I realize it's a difficult question to field without
knowing the system Excel is going out to.
Thanks for the help!