was looking for a better way as the bat file leaves " " at the end of the file or is there a way to have the 3 files created at the same time its 3 queriesSounds like you can use the Shell command to execute the same batch file lines in VBA.
Thanks do you have any sample code for this method?Use the TransferText method and choose the append option. When they're all appended, export the finished file also using TransferText.
Append2TextFile ReadFile(FullPathCSV1), FullPathNewFile
Append2TextFile ReadFile(FullPathCSV2), FullPathNewFile
'Append2TextFile Split(ReadFile(FullPathCSV2), vbCrLf, 2)(1), FullPathNewFile 'without headline
Append2TextFile ReadFile(FullPathCSV3), FullPathNewFile
'Append2TextFile Split(ReadFile(FullPathCSV3), vbCrLf, 2)(1), FullPathNewFile 'without headline
Public Sub Append2TextFile(ByVal Content As String, Optional ByVal TextFile As Variant)
Dim FF As Long
If IsMissing(TextFile) Then TextFile = CurrentProject.Path & "\Log.txt"
FF = FreeFile()
Open TextFile For Append As FF
Print #FF, Content
Close #FF
End Sub
ThanksA text file is a simple text file. You can attach additional text to text. Simple VBA, without occupancy of a temporary table:
A loop at known paths then also makes sense.Code:Append2TextFile ReadFile(FullPathCSV1), FullPathNewFile Append2TextFile ReadFile(FullPathCSV2), FullPathNewFile 'Append2TextFile Split(ReadFile(FullPathCSV2), vbCrLf, 2)(1), FullPathNewFile 'without headline Append2TextFile ReadFile(FullPathCSV3), FullPathNewFile 'Append2TextFile Split(ReadFile(FullPathCSV3), vbCrLf, 2)(1), FullPathNewFile 'without headline
Code:Public Sub Append2TextFile(ByVal Content As String, Optional ByVal TextFile As Variant) Dim FF As Long If IsMissing(TextFile) Then TextFile = CurrentProject.Path & "\Log.txt" FF = FreeFile() Open TextFile For Append As FF Print #FF, Content Close #FF End Sub
VB-Tec / Daten / Dateien / Einlesen - Beliebige Datei einlesen
Beliebige Datei einlesen... Visual Basic-Technik, Beratung, Supportvb-tec.de
A text file is a simple text file. You can attach additional text to text. Simple VBA, without occupancy of a temporary table:
A loop at known paths then also makes sense.Code:Append2TextFile ReadFile(FullPathCSV1), FullPathNewFile Append2TextFile ReadFile(FullPathCSV2), FullPathNewFile 'Append2TextFile Split(ReadFile(FullPathCSV2), vbCrLf, 2)(1), FullPathNewFile 'without headline Append2TextFile ReadFile(FullPathCSV3), FullPathNewFile 'Append2TextFile Split(ReadFile(FullPathCSV3), vbCrLf, 2)(1), FullPathNewFile 'without headline
Code:Public Sub Append2TextFile(ByVal Content As String, Optional ByVal TextFile As Variant) Dim FF As Long If IsMissing(TextFile) Then TextFile = CurrentProject.Path & "\Log.txt" FF = FreeFile() Open TextFile For Append As FF Print #FF, Content Close #FF End Sub
VB-Tec / Daten / Dateien / Einlesen - Beliebige Datei einlesen
Beliebige Datei einlesen... Visual Basic-Technik, Beratung, Supportvb-tec.de
Thanks so i did this and getting errors..A text file is a simple text file. You can attach additional text to text. Simple VBA, without occupancy of a temporary table:
A loop at known paths then also makes sense.Code:Append2TextFile ReadFile(FullPathCSV1), FullPathNewFile Append2TextFile ReadFile(FullPathCSV2), FullPathNewFile 'Append2TextFile Split(ReadFile(FullPathCSV2), vbCrLf, 2)(1), FullPathNewFile 'without headline Append2TextFile ReadFile(FullPathCSV3), FullPathNewFile 'Append2TextFile Split(ReadFile(FullPathCSV3), vbCrLf, 2)(1), FullPathNewFile 'without headline
Code:Public Sub Append2TextFile(ByVal Content As String, Optional ByVal TextFile As Variant) Dim FF As Long If IsMissing(TextFile) Then TextFile = CurrentProject.Path & "\Log.txt" FF = FreeFile() Open TextFile For Append As FF Print #FF, Content Close #FF End Sub
VB-Tec / Daten / Dateien / Einlesen - Beliebige Datei einlesen
Beliebige Datei einlesen... Visual Basic-Technik, Beratung, Supportvb-tec.de
Append2TextFile is a procedure that I have shown and that you have to copy into your code module. Only then it is defined for your VBA project.
For ReadFile the same applies. Also here you have to transfer the function into your code. Probably you have to replace the function argument ByRef by ByVal.