Hi,
I'm wrestling with making a tool to correct often used phrases in SAS code, and then creating a new SAS file with the corrections (or, ideally, overwriting the original). I can read the SAS file, paste it as a cell per row going down, and correct the phrases.
My problem is exporting the rows to a .sas file without adding quotations. This seems to be happening as I'm saving to a new file (so a search and replace beforehand, won't solve the problem).
I've used https://www.extendoffice.com/documen...a-to-text.html as a guide.
My export sub is:
Sub Export()
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
Dim Exp As Integer
On Error Resume Next
Set WorkRng = Application.Selection
Set wb = Application.Workbooks.Add
WorkRng.Copy
wb.Worksheets(1).Paste
saveFile = Application.GetSaveAsFilename(fileFilter:="SAS files (*.sas), *.sas")
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = False
Application.ScreenUpdating = True
End Sub
Which works fine for creating SAS file, but adds the quotation marks like so
"/*libname _input ""&srvpath.\&user_envir.\source\test"";
which should just be (there are quotation marks in the SAS code)
/*libname _input "&srvpath.\&user_envir.\source\test";
I hope some of you can help me!
Cheers
Bookmarks