DDE Printing in Excel

RacerX10

Member
Join Date
Apr 2011
Location
AR
Posts
57
This may be the wrong place for this, but I kinda suspect somebody here has tried to do the same :

I have an excel worksheet updating via DDE and RSLinx. I'm trying to "print on change" via a macro but because the sheet is updating via DDE, the macros I'm using don't seem to detect the change (it's a DDE cell change instead of a user change)

Anybody else run in to this ?

Thanks
 
Which module is the code in? Workbook or worksheet?
Maybe something along this line of thought?
Workbook module: Upon opening, move a value from the cell to a variable (string, double, whatever it is your monitoring).
Public module: The variable should be Public.
Worksheet module: You'll need the macro to recalculate the worksheet. Compare the cell to the variable. Disable change event. If cell <> variable then "Run Print routine", move new cell value to variable, re-enable change event and exit -- else re-enable change event and exit. On err, re-enable change event and exit
Make sure you re-enable the change events before exit.
For samples and ideas try Google. Look for situations where they are monitoring stocks.
Try a couple of different solutions and tweak away.
Remember that each install of an OS and Excel is not identical and what works for one may not work for another.
 
Thanks for the tips .. I've been all over google searching "rslinx dde excel change" but only found links to people having the same problem with solutions that didn't work.

I'll try your ideas and searching for stock-related postings.
 
Write your script to take the "Value" of a cell and put it into a text type variable, say every second then compare it to the previous text, if <> print the variable or array as needed.
The fact that there is DDE or RSlogix is not relevant.
 
Write your script to take the "Value" of a cell and put it into a text type variable, say every second then compare it to the previous text, if <> print the variable or array as needed.
The fact that there is DDE or RSlogix is not relevant.

I'll check in to that, but the fact that it's DDE actually is relevant (at least to the info I've been getting on google) because a USER change is apparently different than a DDE change and excel looks for those changes in different ways (apparently, I'm still learning here)

Something about Worksheet_Change vs Worksheet_Calculate ...

Macros that work fine when I manually change the cell do nothing at all when DDE changes it.

I'm utterly new to macros, etc so if you could post any sample code with instructions on where to put it that would be super helpful.

What I have is cell "A1" updating via DDE. When a user presses a button on the HMI, "A1" is changing from 0 to 1 to 0 again. What I want to happen is for the same worksheet that A1 is on (Sheet1) to print when that cycle happens.

Also possibly relevant : The excel spreadsheet is minimized as a background app, the HMI is foreground while I need the excel sheet doing it's printing minimized.

Thanks !
 
Last edited:
What I advocate is to read the "Value" of the DDE cell and put it into an internal variable, then see if it has changed. This takes it out of the realm of DDE, or Excel and puts it into VBS where you have control.
 
Ok so this is what I have now :

Code:
Option Explicit



Private Sub Worksheet_Change(ByVal Target As Range)

 If Intersect(Target, Range("A1")) Is Nothing Then
 
  Exit Sub
  
 Else
 
  Worksheet_Calculate
  
 End If
 
End Sub




Private Sub Worksheet_Calculate()

Static temp As Double

    temp = Range("A1")
        
    If temp = 1 Then Sheet1.PrintOut

End Sub

.. and it's working for user changes to cell A1. I can't test DDE till this evening when they aren't using the system but thank you so much for your help :)
 
I caught them between cycles and was able to test the excel print function.

Works perfect ! Thanks RussB !
 

Similar Topics

I need to support some old data collection that is running on Excel, but I need to get it running on LibreOffice. The following statement works...
Replies
0
Views
98
Hey Friends. I am currently trying to write approximately 700 tags from FtView13 to an Logix Emulate 5000. I am using rslinx DDE/OPC to create an...
Replies
0
Views
411
I am upgrading an old RSView32 v7.60 HMI to FactoryTalk View SE version 12.0 and I have an issue. There are some excel reports generated daily...
Replies
2
Views
1,024
This used to be an easy task in the past to get data into Excel, now I have 365, Excel just hangs when I paste the link. I've seen some guides to...
Replies
1
Views
1,263
Hi, I'm brand new to the forum and spent some time looking around but could not find an answer to my question. I'm using an excel spreadsheet to...
Replies
3
Views
1,353
Back
Top Bottom