DDE Examples
clc(); try demo_tlbx = get_absolute_file_path("DDE_read_excel.dem.sce"); demo_xls_file = demo_tlbx + 'DDE_DEMO.xls'; disp('Opens Excel with ' + demo_xls_file); winopen(demo_xls_file); catch error(999,'Excel not found'); return; end // Wait Excel sleep(2000); disp('Initialize Connection with Excel'); res = ddeopen('Excel',''); if res then // minimize Excel disp('Minimize Excel'); res = ddeexec('[App.Minimize]'); disp('read data L1C2 from Excel'); Result = ddereq('L1C2'); disp('L1C2: ""' + Result + '"" from ' + demo_xls_file); disp('read data L2C2 from Excel'); Result = ddereq('L2C2'); disp('L2C2: ""' + Result + '"" from ' + demo_xls_file); disp('read data L4C1 from Excel'); Result = ddereq('L4C1'); disp('L4C1: ""' + Result + '"" from ' + demo_xls_file); // maximize Excel disp('Maximize Excel'); ddeexec('[App.Maximize]'); disp('Quit Excel'); ddeexec('[Quit()]'); disp('Close Connection with Excel'); res = ddeclose(); end | ![]() | ![]() |
clc(); try winopen('Excel'); catch error(999,'Excel not found'); return; end // Wait Excel sleep(2000); disp('Initialize Connection with Excel'); res = ddeopen('Excel','[Classeur1]Feuil1'); if res then // minimize Excel disp('Minimize Excel'); ddeexec('[App.Minimize]') STR1 = '[1 2 3]'; disp('Put ""' + STR1 + '"" in ' + 'L1C2'); ddepoke('L1C2', STR1); STR2 = 'Scilab test'; disp('Put ""' + STR2 + '"" in ' + 'L2C2'); ddepoke('L2C2', STR2); disp('Change Font propertie for L2C2'); command_line = '[SELECT(""L2C2"")][FONT.PROPERTIES(,""Bold"")]'; ddeexec(command_line); EXCEL_FILE = TMPDIR + '\DDE_DEMO.xls'; if fileinfo(EXCEL_FILE) <> [] then mdelete(EXCEL_FILE); end command_line = '[SAVE.AS(""' + EXCEL_FILE + '"",1,"""",FALSE,"""",FALSE)]'; disp('Save excel file: ' + EXCEL_FILE); ddeexec(command_line); // maximize Excel disp('Maximize Excel'); ddeexec('[App.Maximize]') disp('Quit Excel'); ddeexec('[Quit()]'); disp('Close Connection with Excel'); ddeclose(); end | ![]() | ![]() |
clc(); try winopen('Excel'); catch error(999,'Excel not found'); return; end // Wait Excel sleep(2000); disp('Initialize Connection with Excel'); res = ddeopen('Excel',''); if res then disp('Create a message box from Excel'); ddeexec('[APP.ACTIVATE][ALERT(""Hello from the sample Excel DDE driver"")]') disp('Quit Excel'); ddeexec('[Quit()]'); disp('Close Connection with Excel'); ddeclose(); end | ![]() | ![]() |
Allan CORNET