Hi Zlerp,
AFAIK, a .bat file is likely to be recognized as MS-DOS script file, so I chose .txt.
In a Standard Module:
Option Explicit
Sub Example()
Dim FSO As Object ' Scripting.FileSystemObject
Dim fsoTStream As Object ' Scripting.TextStream
Dim arrRangeData As Variant
Dim sVersion As String
Dim sPath As String
Dim n As Long
Set FSO = CreateObject("Scripting.FileSystemObject")
sPath = PF(ThisWorkbook.Path)
arrRangeData = Sheet1.Range("E1:E50").Value
If Not FSO.FileExists(sPath & "Output.txt") Then
Set fsoTStream = FSO.CreateTextFile(sPath & "Output.txt", False)
Else
n = 0
Do While FSO.FileExists(sPath & "Output" & sVersion & ".txt")
n = n + 1
sVersion = Format(n, "000")
Loop
If Not n = 999 Then
Set fsoTStream = FSO.CreateTextFile(sPath & "Output" & sVersion & ".txt", False)
Else
MsgBox "Too many files...", vbExclamation, vbNullString
Exit Sub
End If
End If
For n = 1 To UBound(arrRangeData, 1)
fsoTStream.WriteLine arrRangeData(n, 1)
Next
fsoTStream.Close
End Sub
'Path Fixed
Function PF(Path As String, Optional IncludeTrailingSeperator As Boolean = True) As String
Do While Right$(Path, 1) = "\"
Path = Left$(Path, Len(Path) - 1)
Loop
If IncludeTrailingSeperator Then Path = Path & "\"
PF = Path
End Function
See the attached. Does that help?
Mark