Sei sulla pagina 1di 2

14/07/2017 31017 - Using DDE to Read/Write Data from Excel to a Controller

(/app/answers/detail/a_id/31017/page/1#)

Using DDE to Read/Write Data from Excel to a Controller


31017 | Date Created: 02/10/2005 | Last Updated: 07/11/2016
Support
Access Center (/app/home)
Level: TechConnect
 Email this page  Subscribe to Updates
Menu 

Question
Can I use Excel to reading and/or writing data Excel to a Controller using DDE?

Answer
This TechNote provide pseudo code to perform Read and Write data from Controller using Excel VB (Visual Basic) Code, via DDE commands per RSLink Training
Guide.

Read a word (reads T4:0.acc and places in the cell C7 on Sheet1)


Sub Read_Word()

RSIchan=DDEInitiate("RSLinx","[Name of DDE topic on RSLinx]") 'Don't include [] with the name

data=DDERequest(RSIchan,"T4:0.acc")

Range("Sheet1!C7").Formula=data 'Match the sheet name to your excel document

DDETerminate(RSIchan)

End Sub

Read a block of five words (and displays in cells B7-B11 on Sheet1)


Sub Read_Block()

RSIchan=DDEInitiate("RSLinx","[Name of DDE topic on RSLinx]") 'Don't include [] with the name

data=DDERequest(RSIchan,"N7:30,L5,C1")

Range("Sheet1!B7:B11").Formula=data 'Match the sheet name to your excel document

DDETerminate(RSIchan)

End Sub

Write a word (reads T4:0.acc and places in the cell C7 on Sheet1)

Sub Write_Word()

RSIchan=DDEInitiate("RSLinx","[Name of DDE topic on RSLinx]") 'Don't include [] with the name

DDEPoke RSIchan, "T4:0.acc",Range("Sheet1!C7") 'Match the sheet name to your excel document

DDETerminate(RSIchan)

End Sub

Write a block of five words (from cells A7-A11 on Sheet1)


Sub Write Block()

RSIchan=DDEInitiate("RSLinx","[Name of DDE topic on RSLinx]") 'Don't include [] with the name

Top (/app/answers/detail/a_id/31017/page/1#top)
DDEPoke RSIchan, "N7:30,L5,C1",Range("Sheet1!A7:A11") 'Match the sheet name to your excel document

https://rockwellautomation.custhelp.com/app/answers/detail/a_id/31017/page/1 1/2
14/07/2017 31017 - Using DDE to Read/Write Data from Excel to a Controller
DDETerminate(RSIchan)

End Sub

DISCLAIMER
This knowledge base web site is intended to provide general technical information on a particular subject or subjects and is not an exhaustive treatment of such
subjects. Accordingly, the information in this web site is not intended to constitute application, design, software or other professional engineering advice or services.
Before making any decision or taking any action, which might affect your equipment, you should consult a qualified professional advisor.

ROCKWELL AUTOMATION DOES NOT WARRANT THE COMPLETENESS, TIMELINESS OR ACCURACY OF ANY OF THE DATA CONTAINED IN THIS WEB SITE
AND MAY MAKE CHANGES THERETO AT ANY TIME IN ITS SOLE DISCRETION WITHOUT NOTICE. FURTHER, ALL INFORMATION CONVEYED HEREBY IS
PROVIDED TO USERS "AS IS." IN NO EVENT SHALL ROCKWELL BE LIABLE FOR ANY DAMAGES OF ANY KIND INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS PROFIT OR DAMAGE, EVEN IF ROCKWELL AUTOMATION HAVE BEEN ADVISED ON THE POSSIBILITY OF SUCH DAMAGES.

ROCKWELL AUTOMATION DISCLAIMS ALL WARRANTIES WHETHER EXPRESSED OR IMPLIED IN RESPECT OF THE INFORMATION (INCLUDING
SOFTWARE) PROVIDED HEREBY, INCLUDING THE IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, AND NON-
INFRINGEMENT. Note that certain jurisdictions do not countenance the exclusion of implied warranties; thus, this disclaimer may not apply to you.

This page is best viewed in Internet Explorer 11, Edge, Firefox 41, Chrome 46, Safari 9 or newer.

New Site Feedback


Give Feedback

      
(http://www.rockwellautomation.com/global/blog/overview.page)
(https://www.facebook.com/ROKAutomation)
(https://plus.google.com/+RockwellautomationInc)
(https://www.linkedin.com/company/rockwell-
(http://www.slideshare.net/RockwellAutomation)
(http://twitter.com/ROKAutomation)
(http://www.youtube.com/rokautomation)
automation)

Top (/app/answers/detail/a_id/31017/page/1#top)

https://rockwellautomation.custhelp.com/app/answers/detail/a_id/31017/page/1 2/2

Potrebbero piacerti anche