【发布时间】:2019-05-25 21:51:27
【问题描述】:
我使用的是 SAS v9.4
我正在尝试编写一个宏来读取单词模板,进行一些修改,然后将新文档保存为 .docx 文件。我已经设法让它工作以保存到 .doc 文件,但是当我更改扩展名时,我收到以下错误:
文件类型和文件扩展名不兼容
有谁知道我如何将文件保存为 docx 或者这是否可能? 任何帮助将不胜感激
代码如下:
filename sas2word dde 'winword|system';
%macro setupWd(outfile);
options noxsync noxwait xmin;
/* Open Blank Word Document */
data _null_;
length fid rc start stop time 8;
fid=fopen('sas2word','s');
if (fid le 0) then do;
rc=system('start winword');
start=datetime();
stop=start+1;
do while (fid le 0);
fid=fopen('sas2word','s');
time=datetime();
if (time ge stop) then fid=1;
end;
end;
rc=fclose(fid);
run;
/* Save to given location */
data _null_;
file sas2word;
put '[FileSaveAs.Name="' "&outfile" '",.Format=0]';
run;
%mend setupWd;
作品:
%setupWd(outfile = M:\SAS\Output\MacroTest.doc)
不起作用:
%setupWd(outfile = M:\SAS\Output\MacroTest.docx)
【问题讨论】:
-
仅更改名称不会更改文件格式。您正在调用的 FileSaveAs 方法的 FORMAT= 选项的可能值是什么?
-
这是一个很好的观点,老实说不知道选项是什么。 SAS 不是对谷歌最友好的语言,但我会继续尝试:P
-
不是 SAS 问题。这是 SAS 代码调用的 WORD 函数。
-
是的,soz,不知道哪个最好标记,所以我两个都做了
-
DDE 已经过时,不应该使用。改用完全可在 Google 上搜索的 VB 脚本。 DDE 对 Google 不友好,因为它早于 Google。