Control Notepad from Excel

P

Pete

Does anyony know if it is possible to open a note pad
file from excel, enter in some information (All Text)
save the file as a specific name in a specific directory
on the users PC.

Basically what I want to do is this
Open notepad
write some text
save file as "something" in "somewhere"
close notepad
close excel
End

Any help would be appreciated.
Thanks
Pete
 
J

Juan Pablo González

You don't need Notepad to do that. You can do that by using VBA's builtin
commands, like Open, Print # (or Write #), Close, etc.
 
P

Pete

Juan

It really does need to be in a notepad format. I have a
Notepad file .csv that is required to control another
program, or the other program (Visual Basic) is writen to
look for this file in order to perform the funtions
needed.

I have up update this notepad file everyweek and send
this off to 200 sales rep around the country. If they
don't install this notepad file in their PC their sales
reporting tools will not work.

Thanks
Pete
 
D

Dave Peterson

The open/print#/close stuff writes to a plain old text file.

That's what NotePad uses.

Option Explicit
Sub testme()

Dim myFileName As String
Dim FileNum As Long

myFileName = "C:\my documents\excel\outfile.txt"

FileNum = FreeFile
Close FileNum
Open myFileName For Output As FileNum

Print #FileNum, "Here's some text"
Print #FileNum, "from A1: " & ActiveSheet.Range("a1").Text

Close FileNum
End Sub

Try this little example to see if it works (open the output file in NotePad).

Here are three sites that you could steal some code from:

Earl Kiosterud's Text Write program:
www.smokeylake.com/excel
(or directly: http://www.smokeylake.com/excel/text_write_program.htm)

Chip Pearson's:
http://www.cpearson.com/excel/imptext.htm

J.E. McGimpsey's:
http://www.mcgimpsey.com/excel/textfiles.html
 

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