Notepad

A

adrian

Hi all.

Can someone tell me how to write a date or string value to
Notepad so that it can be accessed please.

Someone did answer this for me a while ago but it has
disappeared from the forum.

Many thanks for any help.

Adrian
 
J

Jezebel

Do you mean write directly into Notepad the application? or do you mean
write to a text file that can be opened by Notepad?
 
A

adrian

To a text file that can be opened by notepad.

-----Original Message-----
Do you mean write directly into Notepad the application? or do you mean
write to a text file that can be opened by Notepad?





.
 
J

Jezebel

You can save a Word document as text; but if you're talking about doing this
from VBA, read Help on the Open, Print, and Close statements.
 
A

adrian

Hi Jezabel,

Thank you for your help but I cannot see anything that
does what I want to do.

I do recal that the original posting mentioned the print
statement though.

What I am wanting to do is via vb, create a file that a
variable value can be "printed" into. Then this value can
be "read" back to update the variable value at a later
date.
Meanwhile if the user chooses, the Notepad file can be
opened to view the value that had been saved and edit it
if need be.

I currently use the Open #1 for Input etc staements but
the file that is created cannot be opened by the user for
editing.

Does this help?

Many thanks for your assistance.

Regards
Adrian
 
J

Jan Kronsell

This writes the actual date to a txt file:

Sub WriteToFile()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, s
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CreateTextFile "test1.txt"
Set f = fs.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)
ts.Write Date()
ts.Close

End Sub


Jan
 
J

Jezebel

Your references to Notepad are a bit of a red herring here. Open/Print/Close
and Open/Input/Close can be used for any kind of file, not just text files.

Dim pFileNum as long

pFileNum = freefile

Open "c:\.....Myfil.txt" for as output as #pFileNum
Print #pFileNum, [whatever]
Close #pFileNum

If you're trying to save variable values entirely for use within Word,
consider using DocVariables attached to Normal.dot.
 

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