beautypg.com

Rockwell Automation 1404-M4_M5_M6_M8 Powermonitor 3000 User Manual, PRIOR to Firmware rev. 3.0 User Manual

Page 270

background image

Publication 1404-UM001D-EN-E - October 2004

C-16 Sample Applications

The range Sheet1!D7:D14 is the write source range and the read target
range. The Read graphic element is associated with the following VBA
script or macro:

Sub ReadDateAndTime()

'Open DDE link; the first argument is the application we

'want to DDE with. Second argument is the DDE topic name

'configured in RSLinx

RSIchan = DDEInitiate(“RSLINX”, “DF1_1404_123”)

'Read the date/time table from the PM3000 and put it in

'the excel sheet

Range(“Sheet1!D7:D14”) = DDERequest(RSIchan, “N11:0,L8”)

'Close DDE link

DDETerminate (RSIchan)

End Sub

The Write graphic element is associated with the following VBA script:

Sub WriteDateAndTime()

'Open DDE link

RSIchan = DDEInitiate(“RSLINX”, “DF1_1404_123”)

'Write data from the excel sheet into the PM3000

DDEPoke RSIchan, “N11:0,L8”, Range(“Sheet1!D7:D14”)

'Close DDE link

DDETerminate (RSIchan)

End Sub