Applies To: |
|
Summary: |
How do I access Tags and run Cicode functions from a DDE client such as Microsoft Excel? |
Solution: |
Citect can use DDE I/O Devices to transfer Tag information to and from a DDE server. Citect can also act as a DDE server to clients such as Excel. Clients can access Citect via the DDE topics "system" and "variable". In both cases a DDE link must be opened to the application "citect" and then either a Cicode function can be called using the topic "system" or data can be directly poked in to Tags using the topic "variable". The "system" topic is available at all times, the "variable" topic is only available if the Tag Database is loaded in to memory at startup (This is enabled by default). In Excel select Insert -> macro -> module and add appropriate VB code to modify Tags.
Below is a Cicode function SetINT1() and an example of a procedure in Excel v7.0a ( Office 95 Pro ) that calls the Cicode function SetINT1() using the "system" topic: Cicode: FUNCTION SetINT1(INT Value) Excel Macro: Dim channelNumber As Variant
End Sub This next example is an Excel procedure that uses "poke" to directly change the values of Tags, using the "variable" topic: Sub VariableDDE()
End Sub The last is an example of an Excel procedure to call a Cicode function with string parameters - note the use of double quotes:
Sub CitectMsg() channelNumber =
Application.DDEInitiate(app:="CITECT", Application.DDEExecute
channelNumber, "[Message(""DDE Application.DDETerminate channelNumber End Sub For information on using an older version of Excel, see KB article Q1118. Note that some of the syntax specified in the Excel help for VB functions is misleading. Use the examples provided in the help for accurate function syntax samples. The automatic correction when entering VB macro's is very good and will fix out most syntax errors as they are made. |
Keywords: |
Related Links
Attachments