create and add text to a notepad

A

adrian

Hi all,

I want to create a notepad text file and then add the
current date to it. Then save it to a newly created folder.

I am Ok (I think) on the saving side of things and thanks
to you chaps I can now create folders.

But how do I create the notpad text file and add the date?

Any hints would be gratfully recieved.

Many thanks
Adrian
 
J

Jonathan West

Hi Adrian

adrian said:
Hi all,

I want to create a notepad text file and then add the
current date to it. Then save it to a newly created folder.

I am Ok (I think) on the saving side of things and thanks
to you chaps I can now create folders.

But how do I create the notpad text file and add the date?

Simplest way is to cerate a document, put the text in that you want, and
then use the SaveAs method with the FileFormat set to wdFormatText. That
will create a document that can be read by Notepad.

As for inserting todays date, use this

Selection.InsertAfter Format(Now(), "d mmmm yyyy")


--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 
M

Mark Tangard

Adrian,

Alternatively (going a bit low-tech, but maybe quicker):

Open "C:\MyPath\MyTextFile.TXT" For Output As #1
Print #1, Format(Now, "d mmmm yyyy")
Close #1
 
A

adrian

Hi Johnothan,

Thank you for your response.

I didnt make myself very clear I am afraid.

Actually what I want to do is this:-

'Create a sub folder
mkdir "C:\Incomplete\Images"

'create another subfolder
mkdir "C:\Incomplete\Images\Client"

Then programatically add a text file to the client folder
with the current date on the text file. This file will
then be used to provide the data for a date in a userform.
ie
Create a text document in "C:\Incomplete\Images\Client"
Write to this document todays date.

The reason I want to do it this way is that this mirrors
the way another program adds the date to the same folder
system. And in doing the same way, the date will also be
available to this other program.

I am afraid I do not know the correct term for this text
file, all I know is that the proprties show it as a Text
Document and it opens with Notepad.

Thank you for your continued help

Regards
Adrian
 
J

Jonathan West

adrian said:
Hi Johnothan,

Thank you for your response.

I didnt make myself very clear I am afraid.

Actually what I want to do is this:-

'Create a sub folder
mkdir "C:\Incomplete\Images"

'create another subfolder
mkdir "C:\Incomplete\Images\Client"

OK, we've handled that in another thread.
Then programatically add a text file to the client folder
with the current date on the text file. This file will
then be used to provide the data for a date in a userform.
ie
Create a text document in "C:\Incomplete\Images\Client"
Write to this document todays date.

The reason I want to do it this way is that this mirrors
the way another program adds the date to the same folder
system. And in doing the same way, the date will also be
available to this other program.

I am afraid I do not know the correct term for this text
file, all I know is that the proprties show it as a Text
Document and it opens with Notepad.

You can do this by creating a Word document in the normal way using
Documents.Add, and then saving it using the SaveAs method, with
FileFormat:=wdFormatText. This saves the document as a plain text tile, and
not as a Word document. It will show up in Windows Explorer as a Text
document, and double-clicking it will open it in Notepad. It really does
work, try it!

Alternatively, you can use the basic file I/O commands that Mark Tangard has
suggested. I didn't suggest this initially, because I suspected you would be
more familiar with using VBA to create Word documents.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
 
A

adrian

Thank you johnathan

My mistake, i thought that you were suggesting, initialy,
that I should do it manually.

Thanks for your help

I will do as you say

Regards

Adrian
 

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