Option Explicit
Sub CreateBatchFiles()
Dim rIn As Range
Dim lR As Long
Set rIn = Range("A1").CurrentRegion
For lR = 1 To rIn.Rows.Count
data_to_text_file rIn.Cells(lR, 1), rIn.Cells(lR, 2), rIn.Cells(lR, 3)
Next lR
End Sub
Private Sub data_to_text_file(sPath As String, sFName As String, sCmd As String)
Dim iTextFile As Integer
Dim sMyFile As String
sPath = CheckPath(sPath)
sFName = CheckFName(sFName)
sMyFile = sPath & sFName
iTextFile = FreeFile
Open sMyFile For Output As iTextFile
Print #iTextFile, sCmd
Close #iTextFile
End Sub
Private Function CheckPath(sPath As String) As String
Dim sSep As String
If sPath Like "*/*" Then
sSep = "/"
Else
sSep = "\"
End If
If Not Right(sPath, 1) Like sSep Then
sPath = sPath & sSep
End If
CheckPath = sPath
End Function
Private Function CheckFName(sFName As String) As String
If Not sFName Like "*.bat" Then
sFName = sFName & ".bat"
End If
CheckFName = sFName
End Function