Sign in to follow this  
Followers 0
mulderm

DDEPoke does not working

3 posts in this topic

Hello, I have write the follow VBA-code in Excel: sub test() dim woord as integer dim channelnum as long woord=150 channelnum=DDEInitiate("rslinx", "testsol") DDEPoke channelnum, "N7:0", woord DDETerminate (channelnum) end sub When I run this code nothings happend in N7:0. Why does this not working? I have created a topic and that is working. mulderm

Share this post


Link to post
Share on other sites
I had the same problem, though with Mitsubishi. For some reason the data cannot be from a VBA variable but only from a range. Try this: Sub PLCPOKE(DEVICE As String, DATA As Long) CHANNELNUMBER = Application.DDEInitiate(app:="rslinx", topic:="testsol") Range("DATA_FOR_PLC").Value = DATA Application.DDEPoke CHANNELNUMBER, DEVICE, "DATA_FOR_PLC" Application.DDETerminate CHANNELNUMBER End Sub It must be a cell in Excel named "DATA_FOR_PLC". For bit devices values 0 and 1 are valid. Edited by Sergei Troizky

Share this post


Link to post
Share on other sites
You´re right Sergei. It only works with cell references in Excel. In Access it will works good with a variable name. The right code: sub test() dim channelnum as long Worksheets("DDE").Range("A1").value=150 channelnum=DDEInitiate("rslinx", "testsol") DDEPoke channelnum, "N7:0", Worksheets("DDE").Range("A1") DDETerminate (channelnum) end sub Thanks for the helping. mulderm __________________ Netherlands

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0