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

Re: Making files from VBA? by Jay

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



Re: Making files from VBA? by Helmut

Helmut
Thu Dec 04 09:56:33 CST 2003

Hi Paul,
consult online help for "open" (VBA),
as a start. It's not difficult at all.
Type "open" in your macro, without quotation marks,
press the F1-Key.

Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT4.0



Making files from VBA? by Paul

Paul
Fri Dec 05 08:57:46 CST 2003


Thanks guys :-D!

>-----Original Message-----
>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
>.
>