Excel DDE freeze


Thread Starter


I am using Excel with VBA to poll a CLX plc (actually five). If the DDE link is frozen or not responding while I am polling data, I want to be able to close the application. Any ideas? I was thinking of a while loop to put around the whole routine but am open to other ways.
I would look at stop using DDE and move onto OPC (you would have to pay for this). it has always been easy to break the DDE connection. Instead of polling the PLC's why not do a worksheet change and have the PLCs trigger a cell. However for data archiving with a large amount of tags use OPC, I have found that http://www.opcware.com/opc_excel.html provides the best interfaces for excel.

Hello K Grey,

Raising an error event is probably the cleanest and most efficient way to do this. This routine demonstrates how to raise the event, send an error number and close the application. Hope this helps you out.<pre>
Public Sub RunRoutine()

On Error GoTo DDE_error

' DDE connection failed, raise the error
Err.Raise 5, "DDEFail"

If Err.Number = 5 Then
' close DDE

' save the book and close
End If

End Sub</pre>
I agree with Kevin that OPC is the next generation of DDE and Microsoft has threatened many times to obsolete DDE altogether.

jims [at] sytech.com