Hi Im using Visual Basic 2008 Express Edition, my goal is to read an entire .txt file that works as a template and replace all ocurances of a word with a new one and save th
try the following example I hope it helps
Dim lOpenFile As Long
Dim sFileText As String
Dim sFileName As String
sFileName = "C:\test.txt"
'open the file and read it into a variable
lOpenFile = FreeFile
Open sFileName For Input As lOpenFile
sFileText = Input(LOF(lOpenFile), lOpenFile)
Close lOpenFile
'change 'John Doe' to 'Mary Brown'
sFileText = Replace(sFileText, " John Doe ", " Mary Brown ")
'write it back to the file
lOpenFile = FreeFile
Open sFileName For Output As lOpenFile
Print #lOpenFile, sFileText
Close lOpenFile