Insert lines in notepad (2 Viewers)

davides

Registered User.
Local time
Today, 05:27
Joined
Jun 14, 2010
Messages
11
Hi there !
I want to insert some lines in a txt file(notepad) using vba code. Somethink like:
Code:
line1 bla bla bla
line2 bla bla bla
line3 bla bla bla
line4 bla bla bla
....
and I don`t know the code for inserting a text in a new line ! :( ...

Anyone can help me, please !
Thanks!
 

namliam

The Mailman - AWF VIP
Local time
Today, 14:27
Joined
Aug 11, 2003
Messages
11,695
vbNewLine is the variable for putting in a new line assuming your NOT using notepad but rather using a 'proper' Open, Print/Write, close or a File object.
 

davides

Registered User.
Local time
Today, 05:27
Joined
Jun 14, 2010
Messages
11
@namliam ... in Access Help I don`t see any vbNewLine ... I`m using access 2003 ! I have to use that Notepad ... I can`t put in a report or another object!
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 22:27
Joined
Jan 20, 2009
Messages
12,866
One does not write into a text file with Access via Notepad.

One common technique is to write to the text file via the TextStreamObject.
 

namliam

The Mailman - AWF VIP
Local time
Today, 14:27
Joined
Aug 11, 2003
Messages
11,695
Try this see if you can figure it out from there:
Code:
Sub testNotepad()
Open "C:\TestFile.txt" For Output As #1
Print #1, "Write some text"
Print #1, "Into a notepad"
Print #1, "text file"
Print #1, "make into " & vbNewLine & " make into two lines"
Close #1

End Sub
 

davides

Registered User.
Local time
Today, 05:27
Joined
Jun 14, 2010
Messages
11
GalaxiomAtHome, what do you mean with TextStreamObject ?
 

davides

Registered User.
Local time
Today, 05:27
Joined
Jun 14, 2010
Messages
11
very smart ... I`m new in vba ... Understand me please
 

davides

Registered User.
Local time
Today, 05:27
Joined
Jun 14, 2010
Messages
11
Try this see if you can figure it out from there:
Code:
Sub testNotepad()
Open "C:\TestFile.txt" For Output As #1
Print #1, "Write some text"
Print #1, "Into a notepad"
Print #1, "text file"
Print #1, "make into " & vbNewLine & " make into two lines"
Close #1

End Sub


namliam ... it work your method but it put a character like this " ... at first line and the end line ... how can I remove this simbol?

now I have in txt file somethink like this:
"text1
text2
text3
endtxt"

Regards !
 

namliam

The Mailman - AWF VIP
Local time
Today, 14:27
Joined
Aug 11, 2003
Messages
11,695
change Print to Write, though I thought Print didnt add the " but... can be wrong.
 

Users who are viewing this thread

Top Bottom