I have seen an old post elsewhere (https://www.mrexcel.com/forum/excel-questions/541328-run-dos-command-via-vba.html)
and sort of trying the following to create 2 files (or more I guess) concatenated:-
I can't see what actually happens - too fast I do have a file called Merge.bat but I don't get a merged file (named ABC as textbox2.value).
Contents of .bat file are:-
1 long string with file names separated by space - simple format is as follows
FileA.txt FileB.txt ABC.txt
actual file names are
C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\0A89B723E9501DAD3F2D5CB4F27EBDAB\MQL4\Files\Test_Data\C_03Aug18_EURUSD_6_AUG_start_time_15_00.txt C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\0A89B723E9501DAD3F2D5CB4F27EBDAB\MQL4\Files\Test_Data\C_03Aug18_EURUSD_6_AUG_start_time_15_30.txt C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\0A89B723E9501DAD3F2D5CB4F27EBDAB\MQL4\Files\Test_Data\ABC.txt
seems to 'nearly work' but just can't locate any output (if there is any)
and sort of trying the following to create 2 files (or more I guess) concatenated:-
Code:
Sub test_bat_file(folderPath As String)Dim RetVal, A, fs
'A.writeline "cd PathAllFilesLocated"
Dim My_list As String, fname As String
Set fs = CreateObject("Scripting.FileSystemObject")
fname = folderPath + "Merge.bat"
Set A = fs.CreateTextFile(fname, True)
My_list = "" ' "COPY "
For int1 = 1 To ListBox1.ListCount - 1
If ListBox1.Selected(int1) = True Then
ListBox3.AddItem ListBox1.List(int1)
My_list = My_list + " " & folderPath & ListBox1.List(int1)
End If
Next int1
int1 = int1
My_list = My_list + " " & folderPath & TextBox2.Value + ".txt"
A.writeline My_list 'fname
A.Close
RetVal = Shell(fname, 1)
End Sub
I can't see what actually happens - too fast I do have a file called Merge.bat but I don't get a merged file (named ABC as textbox2.value).
Contents of .bat file are:-
1 long string with file names separated by space - simple format is as follows
FileA.txt FileB.txt ABC.txt
actual file names are
C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\0A89B723E9501DAD3F2D5CB4F27EBDAB\MQL4\Files\Test_Data\C_03Aug18_EURUSD_6_AUG_start_time_15_00.txt C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\0A89B723E9501DAD3F2D5CB4F27EBDAB\MQL4\Files\Test_Data\C_03Aug18_EURUSD_6_AUG_start_time_15_30.txt C:\Users\HOME\AppData\Roaming\MetaQuotes\Terminal\0A89B723E9501DAD3F2D5CB4F27EBDAB\MQL4\Files\Test_Data\ABC.txt
seems to 'nearly work' but just can't locate any output (if there is any)