2012-02-08 48 views
3

當我在運行Office 2007,我的SAS DDE腳本稀少,保存並關閉Excel文件就好了。問題與SAS DDE與Office 2010

我最近更新於2010辦公和居民正常工作......但練成保存對話框停止。我必須手動點擊保存,我以前不必做。

任何人都知道如何解決這個問題?

代碼我使用:

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; 

回答

4

你需要一個(0)添加到您的close語句。這告訴它不要提示。

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);*/ 
+0

謝謝你來搶!我會放棄這一點。 – Adam 2012-02-09 15:35:02

+0

嗨,我今天來問題。如果我想關閉excel文件而不保存它呢?關閉(0)似乎不起作用。 – useR 2014-11-25 08:38:27

+0

@useR'close(0)'確實有效。這段代碼會這樣做:'filename cmdexcel dde'excel | system'; data _null_; 文件cmdexcel; put'[close(0)]'; 跑; 文件名cmdexcel清除;' – 2014-11-25 16:28:34

1

我用下面前:

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

我不能說什麼參數「1」和「假」實現我的避風港沒有DDE文檔可以在網上找到它(它叫做macrofun.hlp,你會在許多SUGI論文中找到它的參考,例如http://www2.sas.com/proceedings/sugi26/p011-26.pdf

在任何情況下,它可能都是我的現在正在調查DDE的替代品,在這個階段相當老舊。