Anthony said:
Is it possible to write batch files using VBA?
If so, could you please provide a sample sub for this?
thank you
Contrary to Doug's take on your question, I think you may be talking
about writing out a batch file (.bat or .vbs) using VBA, so that the
batch file can then be executed. To do that, you can use the basic I/O
statements Open, Print #, and Close. In conjunction with them, you'll
want to use the FreeFile() function to get a free file number. Example
code might look like this:
'----- start of code -----
Dim intFile As Integer
intFile = FreeFile()
Open "C:\Temp\MyBatchFile.bat" For Output As #intFile
Print #intFile, "Line 1 of batch file"
Print #intFile, "Line 2 of batch file"
Close #intFile
'----- end of code -----