dde_toolbox

dde_toolbox Git Source Tree

Root/demos/DDE_read_excel.dem.sce

1// ====================================================================
2// Copyright DIGITEO 2008 - 2011
3// Allan CORNET
4// ====================================================================
5function demo_read_excel()
6
7 clc();
8 try
9 demo_tlbx = get_absolute_file_path("DDE_read_excel.dem.sce");
10 demo_xls_file = demo_tlbx + 'DDE_DEMO.xls';
11 disp('Opens Excel with ' + demo_xls_file);
12 winopen(demo_xls_file);
13 catch
14 error(999,'Excel not found');
15 end
16
17 // Wait Excel
18 sleep(2000);
19
20 disp('Initialize Connection with Excel');
21 res = ddeopen('Excel','');
22
23 if res then
24 // minimize Excel
25 disp('Minimize Excel');
26 res = ddeexec('[App.Minimize]');
27
28 disp('read data L1C2 from Excel');
29 Result = ddereq('L1C2');
30 disp('L1C2: ""' + Result + '"" from ' + demo_xls_file);
31
32 disp('read data L2C2 from Excel');
33 Result = ddereq('L2C2');
34 disp('L2C2: ""' + Result + '"" from ' + demo_xls_file);
35
36 disp('read data L4C1 from Excel');
37 Result = ddereq('L4C1');
38 disp('L4C1: ""' + Result + '"" from ' + demo_xls_file);
39
40 disp('read data L5C1 from Excel');
41 Result = ddereq('L5C1');
42 disp('L5C1: ""' + Result + '"" from ' + demo_xls_file);
43
44 // maximize Excel
45 disp('Maximize Excel');
46 ddeexec('[App.Maximize]');
47
48 disp('Quit Excel');
49 ddeexec('[Quit()]');
50
51 disp('Close Connection with Excel');
52 res = ddeclose();
53 end
54endfunction
55// ====================================================================
56demo_read_excel();
57clear demo_read_excel;
58// ====================================================================
59
60

Archive Download this file

Branches