ISTech Support Forum
http://www.istechforum.com/YaBB.pl Crystal Reports, ODBC & Access >> Access General Issues >> VBA Gurus: Add a single line of text http://www.istechforum.com/YaBB.pl?num=1234905190 Message started by Kelloggs on 02/17/09 at 14:13:10 |
Title: VBA Gurus: Add a single line of text Post by Kelloggs on 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 |
Title: Re: VBA Gurus: Add a single line of text Post by GasGiant on 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. |
ISTech Support Forum » Powered by YaBB 2.1! YaBB © 2000-2005. All Rights Reserved. |