Jay
Thu Dec 04 09:55:01 CST 2003
Paul wrote:
> Hey, I want to create a simple .bat file and a txt from a
> macro. Is this possible? How can I do it?
>
> -Thanks
> Paul
Here are two ways to create equivalent .bat files. To create a .txt file,
just change the extension in the filename.
Sub CreateBat_1()
Open "c:\temp\test1.bat" For Output As #1
Print #1, "@echo off"
Print #1, "dir /w"
Close #1
End Sub
Sub CreateBat_2()
Dim oDoc As Document
Set oDoc = Documents.Add
With oDoc
.Range.Text = "@echo off" & vbCr & "dir /w"
.SaveAs FileName:="c:\temp\test2.bat", _
FileFormat:=wdFormatDOSText
.Close SaveChanges:=wdDoNotSaveChanges
End With
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://www.mvps.org/word