本文介绍了SAS DDE 与 Office 2010 的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行 office 2007 时,我的 SAS DDE 脚本可以很好地填充、保存和关闭 excel 文件.

When I was running office 2007, my SAS DDE script populated, saved and closed the excel file just fine.

我最近更新到了 office 2010 并且人口工作正常...但 excel 在保存对话框处停止.我必须手动单击保存",而我以前不必这样做.

I recently updated to office 2010 and the population works fine...but excel stops at the save dialog box. I have to manually click on Save which I did not have to do before.

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

Anyone know how to fix this issue?

我使用的代码:

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;

推荐答案

您需要将 (0) 添加到您的关闭语句中.这告诉它不要提示.

You need to add a (0) to your close statement. This tells it not to prompt.

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

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

This is my full macro (explains some of the doc type parameters):

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

这篇关于SAS DDE 与 Office 2010 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 05:28