WinWedge is always acting as a DDE Server, even if it is in Keystrokes Mode or Log to Disk mode. While in either of these modes, any valid DDE commands can still be sent to WinWedge. Variables can also be requested, like the record count and individual fields. However, since DDE commands can’t be sent to an external application while in these modes, WinWedge can’t notify other applications of new data readings.
The SetLinkOnData VBA function can overcome this limitation and can sense changes to the data in WinWedge. Specifically, this example uses SetLinkOnData to call a specific subroutine when the record number variable changes in WinWedge. Therefore, if WinWedge is logging data to a disk file or even sending data to an opened application as keystrokes, Excel can still independently log every reading that comes across.
Another benefit of this method is that the data from the Wedge will be transferred to Excel slightly faster than it would if the Wedge were sending a command to Excel after each input.
In addition to using the SetLink and RemoveLink subroutines below, a subroutine needs to be called that facilitates the data transfer between WinWedge and Excel, like the GetData or GetConsectiveFields subroutines from previous examples. This examples assumes that the DDETopic is COM1.
Sub SetLink() ThisWorkbook.Sheets(1).Cells(1, 50).Formula = "=WinWedge|COM1!RecordNumber" ThisWorkbook.SetLinkOnData “WinWedge|COM1!RecordNumber", "GetData" End Sub Sub RemoveLink() ThisWorkbook.Sheets(1).Cells(1, 50).Value = "" ThisWorkbook.SetLinkOnData “WinWedge|COM1!RecordNumber", "" End Sub