bRecursive = False
sFolder = "D:\Users\gci0mxm\Desktop\Test"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWord = CreateObject("Word.Application")
oWord.Visible = True
Set oFolder = oFSO.GetFolder(sFolder)
ConvertFolder(oFolder)
oWord.Quit
Sub ConvertFolder(oFldr)
For Each oFile In oFldr.Files
If LCase(oFSO.GetExtensionName(oFile.Name)) = "rtf" Then
Set oDoc = oWord.Documents.Open(oFile.path)
Str = left(oFile,instr(1,oFile,".")-1)
oWord.ActiveDocument.SaveAs Str & ".pdf", 17
oDoc.Close
End If
Next
If bRecursive Then
For Each oSubfolder In oFldr.Subfolders
ConvertFolder oSubfolder
Next
End If
End Sub
I have created vbs file in linux server but I can't able to run inside the linux server.
Can you help me to run vbs file in linux server or any other alternate solutions for generating pdf from rtf in SAS (HMS/cloud).
You need a VB runtime executable on Linux. Your admins for the SAS server can help you in this regard. And you must be able to run external commands (SAS system option XCMD set), for which you also need your SAS admins.
But this
Word.Documents.Open
makes me suspect that you actually use Word for the conversion. Word is only available on Windows.
LibreOffice is available on Linux and can do such conversions from the commandline, IIRC.
And if the rtf is actually created with SAS, you only need to add ODS PDF to open the pdf destination.
This is not anything related to SAS Administration nor Deployments. The only thing roughly making this something interesting to SAS users in this community is your question is about doing something with data on a SAS hosted platform.
There is nothing built into any SAS product to do this. If the source of the RTF is SAS ODS, simply update the program to use a PDF destination in addition to RTF. If the rtf file is produced outside of SAS then your only chance would be to find a package supported by Red Hat that can accomplish this.
My quick search reveals there is a possibility for LibreOffice to have an ability to take an RTF files and convert it to a PDF. See the --convert-to argument in the LibreOffice documentation here.
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.