首页 > 解决方案 > How to run VB.NET with X command in SAS through Enterprise

问题描述

I am trying to use the following sas programs to convert multiple rtf files into pdf files by using the VB.NET (X command). It worked perfectly in PC sas. However, while using it in the SAS Enterprise, it gave no error message but didn't perform the pdf convertion.

Does anyone know what's happening in here? What should I do to make this work again? Thanks!

    %macro vbs_pdf(rtfname=,pdfname=);
        data _null_;
             length vbscmd $ 400;
             file "temp.vbs";
             put 'Dim ObjWord';
             put 'set objWord = CreateObject("Word.Application")';
             put 'objWord.Visible = True';
             vbscmd='objWord.Documents.Open("'|| "&rtfname" ||'")';
             put vbscmd;
             vbscmd='objWord.ActiveDocument.SaveAs "'||"&pdfname"||'", 17';
             put vbscmd;
             put 'objWord.ActiveDocument.Close(False)';
             put 'objWord.Application.Quit(False)';
        run;options noxwait;
        data _null_;
             command="START /WAIT CScript temp.vbs //NoLogo";
             call system(command);
             command2="DEL temp.vbs ";
             call system(command2);
        run;
    %mend;

    options noxwait;

    data &prefix._toc; 
         set &prefix._toc; 
    call symput('count',compress(put(_n_,best.)));
    run;
    proc sql noprint;
         select filename
         into : rtf1- :rtf&count
         from &prefix._toc;
    run;

    %macro cvtpdfs;
        %do i=1 %to &count;
        %let mypdf=%scan(&&rtf&i,1,'.');
        %vbs_pdf(rtfname=&file2path./&&rtf&i,pdfname=&curpath/documents/pdf/&mypdf..pdf);
        %end;
    %mend;

    %cvtpdfs; 

标签: vb.netpdfsasrtf

解决方案


By default SAS EG has X commands disabled. In your SAS configuration files for EG you will see -NOXCMD. You will see more here: https://blogs.sas.com/content/sasdummy/2009/11/19/using-the-x-and-systask-commands-from-sas-enterprise-guide/


推荐阅读