Hi All,
I have a following code in VBa that I am using
Instead of using "Range("j2")" value from my excel which can be different in a text file ( and in this case the cript will not do anythnig). Is it possible to use something like "Speed=" and two character to the right?
Is there any solution for this?
Thanks in advance,
Philip
I have a following code in VBa that I am using
VBA Code:
Sub replace_txt()
Dim sBuf As String
Dim sTemp As String
Dim iFileNum As Integer
Dim sFileName As String
'Lewis Hamilton
'File to edit
sFileName = "F:\Program Files (x86)\Steam\steamapps\common\Automobilista\GameData\Talent\F1-2019\LHamilton.rcd"
iFileNum = FreeFile
Open sFileName For Input As iFileNum
Do Until EOF(iFileNum)
Line Input #iFileNum, sBuf
sTemp = sTemp & sBuf & vbCrLf
Loop
Close iFileNum
'Replace text
sTemp = Replace(sTemp, "Speed=" & Range("j2"), "Speed=" & Range("k2"))
'Create new file and write out sTemp which is the original file with the replaced text
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile("F:\Program Files (x86)\Steam\steamapps\common\Automobilista\GameData\Talent\F1-2019\LHamilton.rcd")
oFile.WriteLine sTemp
oFile.Close
End Sub
Instead of using "Range("j2")" value from my excel which can be different in a text file ( and in this case the cript will not do anythnig). Is it possible to use something like "Speed=" and two character to the right?
Is there any solution for this?
Thanks in advance,
Philip