Opening Notepad from Excel

A

Ayo

I am trying to write a VBA code that does the following:
1. open Notepad from inside Excel
2. Save a blank file (i.e, Save as Test.kml)
3. Close the Notepad
 
D

Dave Peterson

You want a 0 byte file?

Option Explicit
Sub testme()

Open "C:\Test.kml" For Output As 1
Close #1

End Sub

Be careful with this. If that file exists, then it's emptied. If it doesn't
exist, it'll be created.

(Change the path to what you want.)
 
J

joel

You don't need to run notepad. Just create the file and close it.

Const ForReading = 1, ForWriting = -2, _
ForAppending = 3

WriteFile = "c:\temp\Test.kml"
Set fs = CreateObject("Scripting.FileSystemObject")
Set fout = fs.CreateTextFile _
(Filename:=WriteFile, overwrite:=True)

fout.Clos
 
A

Ayo

Thanks

Dave Peterson said:
You want a 0 byte file?

Option Explicit
Sub testme()

Open "C:\Test.kml" For Output As 1
Close #1

End Sub

Be careful with this. If that file exists, then it's emptied. If it doesn't
exist, it'll be created.

(Change the path to what you want.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top