Copy And Replace Simple Text In A Txt File Using

[Solved] Copy And Replace Simple Text In A Txt File Using | Vb - Code Explorer | yomemimo.com
Question : Copy and replace simple text in a txt file using vbs

Answered by : hackoo

Option Explicit
Const ForReading = 1
Const ForWriting = 2
Dim objFSO,objFile,strText,strNewText,objRegEx
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Users\newtons\Desktop\Text.txt",ForReading)
strText = objFile.ReadAll
objFile.Close
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.IgnoreCase = True
objRegEx.Pattern = "jim"
strNewText = objRegEx.Replace(strText,"James")
Set objFile = objFSO.OpenTextFile("C:\Users\newtons\Desktop\Text.txt",ForWriting)
objFile.WriteLine strNewText
objFile.Close
set objFSO = Nothing
set objFile = Nothing

Source : https://stackoverflow.com/questions/30393376/copy-and-replace-simple-text-in-a-txt-file-using-vbs/30393728#30393728 | Last Update : Wed, 24 Aug 22

Answers related to copy and replace simple text in a txt file using vbs

Code Explorer Popular Question For Vb