Good morning
I have a txt file named "txt" with 4 lines. And my probleme is that I want to delete the 2 last words in the 3 last lines.
This is my text in txt :
"vol"
"vui one high" one high
"vui one front " two high
"vuil high front " three high
And the words to delete is the 2 after the quote marks.
I have a code but at this moment it allow only to replace a word Here is the start of my code :
Sub CommandButton1_Click()
Dim sBuf As String
Dim sTemp As String
Dim iFileNum As Integer
Dim sFileName As String
' Edit as needed
sFileName = "C:\Users\bquinty\Desktop\txt.txt"
iFileNum = FreeFile
Open sFileName For Input As iFileNum
Do Until EOF(iFileNum)
Line Input #iFileNum, sBuf
sTemp = sTemp & sBuf & vbCrLf
Loop
Close iFileNum
sTemp = Replace(sTemp, "word to remplace", "word wanted")
'Save txt file as (if possible)
iFileNum = FreeFile
sFileName = "C:\Users\bquinty\Desktop\txt.txt"
Open sFileName For Output As iFileNum
Print #iFileNum, sTemp
Close iFileNum
End Sub
Thanks for all help/advice that you can give me.