options noxwait noxsync;
x '"D:\报表模板.xlsx"';
data _null_;
rc=sleep(2);
run;
filename cmds dde 'excel|system';
data _null_;
file cmds;
/* Insert an Excel Macro Sheet */
put '[workbook.insert(3)]';
run;
/* Direct the Output to the Newly created Macro Sheet */
filename xlmacro dde 'excel|macro1!r1c1:r5c1' notab;
data _null_;
file xlmacro;
put '=workbook.name("sheet1","NewSheet")';
put '=halt(true)';
/* Dump the contents of the buffer, allowing us to both write and */
/* execute the macro in the same DATA Step */
put '!dde_flush';
file cmds;
/* Run Macro1 */
put '[workbook.activate("Sheet1")]';
put '[SELECT("r5c3:r60c9")]';
put '[SORT(1,"r5c3",1)]'; *从第5行开始,对C列(r5c3)进行排序;
put '[run("macro1!r1c1")]'; *执行macro1表中第一行第一列中(r1c1)的命令;
put '[error(false)]';
/* delete the Macro Sheet */
put '[workbook.delete("macro1")]'; *删除宏表macro1的命令;
*put '[workbook.delete("NewSheet!c3:c3")]';
*put '[workbook.NewSheet.delete("c3:c3")]';
run;
尝试了*put '[workbook.delete("NewSheet!c3:c3")]';
*put '[workbook.NewSheet.delete("c3:c3")]';
试图在DDE中删除模板表中的第3列,不过不成功 ,求牛人们解答