I have the following VBA code (below) that I am attempting to run against each of my 21 worksheets.
The idea is that each worksheet should get saved out as a .bat filetype - and simply contain the text exactly as it appeared in each respective worksheet.
The problem is, the text contained in the generated .bat files include quotes "" that were not in the actual worksheets themselves.
How do I get around this issue?
Here is my VBA code:
Here is a sample of how the data should look
Versus how the above actually looks when ran through the VBA code:
"set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%"
"echo %curr_date%"""
"command -k -g https://logintosite -u un -p pw data.source @""\\datasource\gvl\SHARED\Something Something Team\VendorX\Automation\XML\Master File.xml"" -o ""\\datasource.net\gvl\SHARED\Something Something Team\VendorX\Automation\Bat\Master File 2022-11-21.csv"" -H"
FYI - I have also tried changing the format to xlTextPrinter per:
Application.ActiveWorkbook.SaveAs Filename:=xTextFile, FileFormat:=xlTextPrinter, CreateBackup:=False
But it butchers my outputted .bat text, cutting off lines and starting new lines - thus rendering the code inoperative.
The idea is that each worksheet should get saved out as a .bat filetype - and simply contain the text exactly as it appeared in each respective worksheet.
The problem is, the text contained in the generated .bat files include quotes "" that were not in the actual worksheets themselves.
How do I get around this issue?
Here is my VBA code:
VBA Code:
Sub ExportSheetsToCSV()
Dim xWs As Worksheet
Dim xcsvFile As String
For Each xWs In Application.ActiveWorkbook.Worksheets
xWs.Copy
xcsvFile = CurDir & "\" & xWs.Name & ".bat"
Application.ActiveWorkbook.SaveAs Filename:=xcsvFile, _
FileFormat:=xlCSV, CreateBackup:=False
Application.ActiveWorkbook.Saved = True
Application.ActiveWorkbook.Close
Next
End Sub
Here is a sample of how the data should look
set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2% |
echo %curr_date%" |
command -k -g https://logintosite -u un -p pw data.source @"\\datasource\gvl\SHARED\Something Something Team\VendorX\Automation\XML\Master File.xml" -o "\\datasource.net\gvl\SHARED\Something Something Team\VendorX\Automation\Bat\Master File 2022-11-21.csv" -H |
Versus how the above actually looks when ran through the VBA code:
"set curr_date=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%"
"echo %curr_date%"""
"command -k -g https://logintosite -u un -p pw data.source @""\\datasource\gvl\SHARED\Something Something Team\VendorX\Automation\XML\Master File.xml"" -o ""\\datasource.net\gvl\SHARED\Something Something Team\VendorX\Automation\Bat\Master File 2022-11-21.csv"" -H"
FYI - I have also tried changing the format to xlTextPrinter per:
Application.ActiveWorkbook.SaveAs Filename:=xTextFile, FileFormat:=xlTextPrinter, CreateBackup:=False
But it butchers my outputted .bat text, cutting off lines and starting new lines - thus rendering the code inoperative.