polarisking
Member
This is driving me nuts. I'm merging all files with the mask *.txt into one .txt file using a DOS shell command.
The command is Shell Environ$("COMSPEC") & " /c Copy C:\TEST\*.txt C:\TEST\CombinedFile.txt "
I'd like to use variables for both the From and To environments. Because there's a leading space before the To environment, DOS is expecting a end result format of
" "Path and Target Filename"" (that's what you see if you hover over the variable name in VBA)
I cannot seem to get there, no matter how I try. Any advice?
This works: Target = " ""C:\Users\PL18861\Desktop\Work Area\WA001\AllFiles.txt""" 'Notice leading space
This does not: Target = " " & Range("Target") & Chr(34)
Target = " " & Range("Target") & Chr(34)
Call Shell(Environ("COMSPEC") & " /c copy " & Src_Pattern & Target, vbMinimizedNoFocus)
If you hover over the word target in the line above, this is how it resolves
The command is Shell Environ$("COMSPEC") & " /c Copy C:\TEST\*.txt C:\TEST\CombinedFile.txt "
I'd like to use variables for both the From and To environments. Because there's a leading space before the To environment, DOS is expecting a end result format of
" "Path and Target Filename"" (that's what you see if you hover over the variable name in VBA)
I cannot seem to get there, no matter how I try. Any advice?
This works: Target = " ""C:\Users\PL18861\Desktop\Work Area\WA001\AllFiles.txt""" 'Notice leading space
This does not: Target = " " & Range("Target") & Chr(34)
Target = " " & Range("Target") & Chr(34)
Call Shell(Environ("COMSPEC") & " /c copy " & Src_Pattern & Target, vbMinimizedNoFocus)
If you hover over the word target in the line above, this is how it resolves