BookmarkSubscribeRSS Feed
PanicLi
Calcite | Level 5

Hi all,

 

Do anyone know how to recover the function of "ODS RTF"?

I just wanted to compile several RTF files and performed DDE function.

However, the program of "ODS RTF" function is no longer work (I need RTF files with the header, the footer, and some RTF texts, like figure below) after performing DDE function unsuccessfully!!!!

Fig2.jpg

 

Here are my codes:

"

/*CODE for compiling RTF files*/

%MACRO try_comrtf(path);

filename dirlist pipe "dir ""&path."" /b ";

data dirlist1 ; infile dirlist length=reclen ;

input filename $varying1024. reclen ;

if scan(filename,2,'.') in ('doc' 'rtf'); path="&path.";

filename=strip(path)||'\'||strip(filename);

run;

 

proc sql noprint;

select count(*) into:n from dirlist1;

select filename into:file1-:file%cmpres(&n) from dirlist1;

quit;

%put &n.;

 

%let rc=%sysfunc(system(start winword));

data _null_; x=sleep(5);

run;

 

filename word DDE 'Winword|System';

data _null_; file word;

put '[FileOpen .Name = "' "&file1" '"]';

%do i=2 %to &n;

put '[EndOfDocument]';

put '[InsertBreak .Type = 2]';

put '[InsertFile .Name ="' "&&file&i." '" ]';

%end;

 

put '[FileSaveAs .Name="master", .format=6]';

put '[FileSave]';

put '[FileCloseAll]';

put '[FileExit]';

run;

%mend;

%try_comrtf(path= D:\XXX_WORK\SAS_Practice\Try macro\Out);

 

/*CODE for RTF*/

options nonumber;

ODS RTF FILE ="D:\XXX_WORK\SAS_Practice\Try_Output\doc1.rtf" style=journal;

ods escapechar='@';

title1 height=12pt font="Times New Roman" j=left "CRF version: " j=center "Personal Try" j=right "Protocol version: No.00000";

title2 height=12pt font="Times New Roman" bold j=center "Table 1";

title3 height=12pt font="Times New Roman" j=left "Summary of Age" j=right "@{thispage} of @{lastpage}";

footnote1 height=10pt font="Times New Roman" j=right "Page: @{lastpage}";

 

PROC REPORT data = CTI_PORT_A_ALL NOWD

style(report)=[background=white just=left font=(Times, 12pt) color=black]

style(header)=[background=white just=left font=(Times, 12pt) color=black]

style(column)=[background=white just=left font=(Times, 12pt) color=black]

style(lines)=[background=white just=left font=(Times, 12pt) color=black];

 

column order varnam class output ;

define order/ order noprint;

compute after/style=[just=l];

LINE "SD=standard deviation; CI=confidence interval";

ENDCOMP;

RUN;

ODS RTF CLOSE;

"

Could anyone help me to solve the big problem!!??

 

Thank you so much!!

2 REPLIES 2
Reeza
Super User

When was the last time this worked? Also - which parts of your code are not working specifically? Is it the ODS RTF section or the DDE? I suspect it's not both sections that are broken.

 

If it's the DDE section, Microsoft disabled DDE a few months ago (Nov or Dec 2017) in an update because of a malware issue. You likely either need to re-enable it - if your security team will allow it or find a different workaround. SInce your DDE looks like it's just combining RTF files, I'd probably recommend a VBS option instead. 

 

Since you have X command enabled, you can still call the VBS using an X command.

 

 

PanicLi
Calcite | Level 5

Hi Reeza,

 

Thanks for your reply.

 

The program of ODS RTF did work. I mean, the header, the footer, and all other settings can be seen in the RTF files before performing DDE.

But all of them were disappeared after DDE failure.

Although all RTF files were compiled into one file, all these settings were gone!!! just like the figure below:

Fig1.jpg

 

And when I checked the "materials" (RTF files saved before I performed DDE), all of had become the ones like the photo above.

What can I do to fix the "accident"? should I removed and reinstalled Word? or how can I correct the program?

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 770 views
  • 0 likes
  • 2 in conversation