The OriginPro samples demonstrate using Origin as a DDE Server. Using Origin as a DDE Client does require some LabTalk programming except in a specific case.
Here is an example that retrieves data from Excel in blocks of 5 rows by 5 columns. Set up an Excel worksheet with 100 rows of 5 columns of data. The first column should be your increasing X values. Now run this script in Origin:
for(ready=0,attempts=0;ready==0&&attempts<10;attempts++) {
dde -c Excel|System idSys;
sec -p 1;
if(idSys>=0) ready=1;
}
if(attempts>=10) {
type -a Request timed out. Terminating...;
break1;
} else {
type -a Connected, retrieving info.;
}
dde -r idSys Topics;
dde -d idSys;
ii=1;
getn (Select a Topic:) ii:Z (Excel System Topics);
dde -c Excel|%[%Z,#ii] idXL;
wo -a 2;
set %H -e 100;
wo -s 0 0 0 0;
wo -p 201 scatter;
x2=100;y2=10;
currentrow=1;
blocksize=5;
reps=20;
delay=1;
repeat reps {
dde -rc idXL R$(currentrow)C1:R$(currentrow+blocksize-1)C26 Data1!R$(currentrow)C1:R$(currentrow+blocksize-1)C26;
currentrow+=blocksize;
sec -p delay;
};
dde -d idXL;
type Finished.;
The script first establishes that Excel is running, then offers the user a choice of DDE 'Topics' - select the worksheet you already setup. The data is brought into Origin in rows of 5 and plotted at one second intervals.
Here is an example that doesn't involve LabTalk scripting:
- Open an Excel workbook or worksheet file.
- Select a region in a sheet.
- Select Edit : Copy
- Go to Origin and click in the home cell of a worksheet (Row 1, Column 1).
- Select Edit : Paste Link
That's it. There is now a DDE link between the Excel region and the Origin worksheet (one-way, from Excel to Origin). If you make a change in the Excel worksheet, that change is sent to Origin via DDE.