I am currently using the following VBA code to copy and paste a range of data in an excel file to create a Batch file. I am running into the following problems:
- Quotations are being placed around individual cell contents
- I am losing the character return
Here is what my data that is copied, each line listed below needs to copy on another line in the batch file:
@ftp -i -s:"%~f0"&GOTO:EOF
open ecggwprd.uhc.com
if1**79
W88***3k
bin
put \\Nas00233pn\ACP_Finance_Ops\FTP\Ced.201602.zip /cedarhill/Ced.201602.zip
!ping -n 30 0.0.0.0 > NULL
CD /ced
dir Q__C_
Does anyone know how I can modify my VBA code to correct these items?
Here is a copy of my code:
Sub savebat()
Dim wbSource As Workbook
Dim wsSource As Worksheet
Dim wbDest As Workbook
Dim fName As String
Set wbSource = ActiveWorkbook
Set wsSource = ActiveSheet
Set wbDest = Workbooks.Add
wsSource.Range("A1:A51").Copy
'----------------------------
'Save in new workbook
wbDest.Worksheets(1).Cells(1, 1).PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Application.CutCopyMode = False
Application.CutCopyMode = False
'Get file name and location from user
fName = Application.GetSaveAsFilename(FileFilter:="bat (*.bat), *.bat", Title:="Save As")
If fName = "" Then Exit Sub '//user cancelled
'Save new bat file
wbDest.SaveAs fName, FileFormat:=xlText
wbDest.Close SaveChanges:=True
'----------------------------
End Sub