Questions? Search our site or call us at 1-800-722-6004

Requesting Data from WinWedge using SetLinkOnData Method

The VBA SetLinkOnData Method is Useful for Collecting Data through DDE While in Keystrokes Mode

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

Categories: Macro / Code Sample, Microsoft Excel, Data Collection, Serial (RS232), WinWedge

Last Updated: 2015.07.07

Need more help?

Don't hesitate to call or email us with your questions

Our office is open 9AM - 5PM Monday Through Friday (E.S.T.)

Technical Support: 215-496-0202

Toll-Free: 1 (800) 722-6004
Skype: taltech1 (Voice only)
Email: support@TALtech.com