Welcome, Guest. Please Login.
04/19/24 at 16:24:34
News:
Home Help Search Login


Pages: 1
Send Topic Print
VBA Gurus: Add a single line of text (Read 1355 times)
Kelloggs
Active Member
*****


Do crazy people know
they are crazy?

Posts: 785
Gender: male
VBA Gurus: Add a single line of text
02/17/09 at 14:13:10
 
I need to insert  a line into a text file
 
This is my text file
 
Canada
USA
England
 
How do I insert some text between lines 1 and 2?
 
Canada
France
USA
England
 
Can it be done with VBA?
 
Thank you all,
 
Kelloggs
 
 
Function insert_fnpath()
Dim fso As New Scripting.FileSystemObject
Dim thepath As String
Dim ftext
Dim ntext
 
thepath = "N:\1CNC\DATA\625\FISCON0100\6252018.txt"
 
Set ftext = fso.OpenTextFile(thepath, ForReading)
 
x = ftext.ReadLine
ftext.SkipLine
x = ftext.Read(4)
ftext.Close
 
Select Case x
 
Case "(FN-"
    'Overwrite line with "(FX-)
 
 
Case Else
    'Insert New Line after Line 2
 
End Select
 
Set fso = Nothing
 
end Function
 
Back to top
 
 

Evo ERP - 35 Users
Dumped MS Access like a hot potato (VB.Net rules!!!)
Email WWW   IP Logged
GasGiant
Administrator
*****


How can I help?

Posts: 1523
Gender: male
Re: VBA Gurus: Add a single line of text
Reply #1 - 02/17/09 at 20:08:51
 
I am not a VBA guru, but I would load the file, insert the line, then write the file out.
Back to top
 
 


Email WWW GasGiant GasGiant 31012781 swordworlder swordworlder   IP Logged
Pages: 1
Send Topic Print