more excel DDE problems

Join Date
Mar 2009
Location
Charleston SC
Posts
8
:unsure:Ok I have figured out how to unpack a 16 bit word in excel from a DDE server. Also figured out how to get the word in excel cell formula (=ovs|slow!"tagname") Ovs being the server name, slow is the 1 second update rate (fast updates 300ms). The issue is I have about 300 tags I want to put in the spread sheet for trouble shooting purposes. I do not want to possibly crash the network by having all 300 tags update continiously. I was able to record a macro that sets the location to 0 when not in use and also set the location to the above format. However I will have to do that for every tag/word I use and that would be 300 seperate macro's. In the formula bar I can enter "=ovs|slow!"&"tag name" and it will string the complete address to a cell but that is not the same as putting in a formula even though it looks the same. Tried several variations in VB but nothing seems to work. Has anybody done this before?

This code has worked for others but the application was used in conjunction with DataHub :

GetInput Macro

sub GetInput()
mychannel=DDEInitiate("datahub","default")
NewVal=DDERequest(mychannel,"my_pointname")
sheet1.cells(2,3)=NewVal

my_pointname is a selection from the DataHub.

I tried:

sub GetInput()
location=DDEInitiate(server,network)'ovs|slow'
dim tagName as string (tried as Double, Long, Object ect.)
tagName=(used one of my tag names)
NewVal=DDERequest(location,TagName)
sheet1.cells(2,22)=NewVal
 
My own reply

:pFigued out a macro that works. Probably not the best way to accomplish the task but it works! Given the fact my VBA experience is 4 days. Thought I would pass the knowledge on so someone else does not get the butt kicken I got. LOL

Excel\Tools\Macro

create new macro
Called mine "GetTag"

Sub GetTag()
A="ovs|slow!" 'standard prefix to DDE coms.'
B=Selection.offset(0,-1) 'my tag name was in same row as the
Cell reading the word off the DDE
network and one col. to the left.
Format (row offset, Col offset)'
Value= "=" & A & B
ActiveCell=Value

End Sub

For those who are not familure with running Macros in excel here is how I used mine. I put my Tag name in cell A1 and clicked Cell B1 went to tools/Macro clicked on GetTag and clicked Run. You can also go to View/Forms add a button Assign Macro pops up. Click on GetTag. In order for this to work you have to have the cell active. In my case B1 needed to be the selected cell. Click on the button and it runs the Macro. I added another button to write a 0 to the active cell to deactivate GetTag. Simple Macro:

Sub StpTag ()
ActiveCell=0
End Sub

Probably a better way to do this. Trying to figure out how to just hit the button and it does the job no matter what cell is active. But I have way to much time invested in just getting 4 lines of code to work. Save that project for another day:)

Hope this helps somebody.
 

Similar Topics

Hello, i need to use P_Intlk and feed the Status interlock OK bit to a P_DOut block. However, there's 17 interlocks for this output. How can I...
Replies
1
Views
107
Hi everyone, recently i worked with a cmore panel and have the question that how can clear alarm list whit remote form,right now only can with...
Replies
0
Views
107
Hello, friends, I am trying to upgrade a system that uses an Onrom incremental encoder (E6B2-CWZ6C) connected to a Danfoss VFD (FC360), but now...
Replies
4
Views
271
Hello Friends I have took the sample program from AB webpage and modified, but I can only send 127 chars...
Replies
1
Views
178
Hello, I am new here and have been working with PLCs for a few years now. I have been tasked with setting up a Micrologix 1400….. to a Cmore 10...
Replies
10
Views
486
Back
Top Bottom