【问题标题】:Problems with SAS DDE with Office 2010SAS DDE 与 Office 2010 的问题
【发布时间】:2012-02-09 05:05:43
【问题描述】:

当我运行 Office 2007 时,我的 SAS DDE 脚本填充、保存并关闭了 excel 文件就好了。

我最近更新到 Office 2010 并且人口工作正常...但 excel 在保存对话框中停止。我必须手动点击以前不需要的保存。

有人知道如何解决这个问题吗?

我正在使用的代码:

filename commands DDE 'EXCEL|SYSTEM';
data _null_;
file commands;
put '[OPEN("pathtoexcelfile.xls")]';
run;

data _null_;
file commands;
put "[Save.as(""&saveas_Path.&saveas..xls"")]";
put "[Close]";
run;

【问题讨论】:

    标签: sas


    【解决方案1】:

    您需要在您的关闭声明中添加(0)。这告诉它不要提示。

    data _null_;
    file commands;
    put "[Save.as(""&saveas_Path.&saveas..xls"")]";
    put "[Close(0)]";
    run;
    

    这是我的完整宏(解释了一些文档类型参数):

    /******************************************************************************
    ** PROGRAM:  MACRO.DDE_SAVE_AS.SAS
    **
    ** DESCRIPTION: SAVES THE CURRENT EXCEL FILE.  IF THE FILE
    **              ALREADY EXISTS IT WILL BE OVERWRITTEN.
    **
    ** PARAMETERS: iSAVEAS: THE DESTINATION FILENAME TO SAVE TO.
    **             iType  : (OPTIONAL. DEFAULT=BLANK). 
    **                      BLANK = XL DEFAULT SAVE TYPE
    **                          1 = XLS DOC - OLD SCHOOL! PRE OFFICE 2007?
    **                         44 = HTML - PRETTY COOL! CHECK IT OUT... 
    **                         51 = XLSX DOC - OFFICE 2007 ONWARDS COMPATIBLE?
    **                         57 = PDF
    ** 
    ** NOTES:  IF YOU ARE GETTING A DDE ERROR WHEN RUNNING THIS MACRO THEN DOUBLE
    **         CHECK YOU HAVE PERMISSIONS TO SAVE WHERE YOU ARE TRYING TO SAVE THE
    **         FILE.
    ** 
    *******************************************************************************
    ** VERSION:
    ** 1.0 ON: 01APR10 BY: RP
    **     CREATED.  
    ******************************************************************************/
    
    %macro dde_save_as(iSaveAs=,iType=);
      %local iDocTypeClause;
    
      %let iDocTypeClause=;
      %if "&iType" ne "" %then %do;
        %let iDocTypeClause=,&iType;
      %end;
    
      filename cmdexcel dde 'excel|system';
      data _null_;
        file cmdexcel;
        put '[error(false)]';
        put "%str([save.as(%"&iSaveAs%"&iDocTypeClause)])";
        put '[error(true)]';
      run;
      filename cmdexcel clear;
    
    %mend;
    /*%dde_save_as(iSaveAs=d:\rrobxltest, iType=44);*/
    

    【讨论】:

    • 谢谢罗伯!我会试一试的。
    • 嗨,我今天来 dde ​​问题。如果我想关闭excel文件而不保存它怎么办? close(0) 似乎不起作用。
    • @user close(0) 确实有效。这段代码可以做到:filename cmdexcel dde 'excel|system'; data _null_; file cmdexcel; put '[close(0)]'; run; filename cmdexcel clear;
    【解决方案2】:

    我以前用过以下:

    put '[save.as("' "&savepath\&savename..&save_ext" '",1,,false,,false)]';
    

    我不能说参数“1”和“false”实现了什么,因为我手头没有 DDE 文档,也无法在网上找到它(它被称为 macrofun.hlp,你会找到对它在许多 SUGI 论文中,例如http://www2.sas.com/proceedings/sugi26/p011-26.pdf)

    无论如何,可能值得研究 DDE 的替代品,因为它在这个阶段已经相当老了。

    【讨论】:

      猜你喜欢
      • 2012-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-22
      • 1970-01-01
      相关资源
      最近更新 更多