Error DataBase-One Place all Solutions Forums Blog Glossary    Contact Us
Search  
   
Browse by Category
Error DataBase-One Place all Solutions .: Operating Systems .: Windows Operating Systems .: Windows Scripts and Batch Files .: VB Script to Replace Text in a File

VB Script to Replace Text in a File

Dim FSO, ReplaceTab, ObjShl, AllText, ObjFso, CreateFile, TristateFalse
Dim SourceFile, SourceUserInput, DestFile, DestUserInput, FileExist

SourceUserInput = InputBox("Please choose source file?", "Where is the File", "C:\Temp\Source.txt")
DestUserInput = InputBox("Please choose Destination file?", "Where is the File", "C:\Temp\Destination.txt")
TristateFalse = 0

' Variables
Sourcefile = SourceUserInput
DestFile = DestUserInput

Set Fso = CreateObject("Scripting.FileSystemObject")

Set ObjShl = Fso.OpenTextFile(SourceUserInput, 1)
AllText = ObjShl.ReadAll
ObjShl.Close

ReplaceTab = Replace(AllText, vbTab, ":")

Set ObjFso = Fso.CreateTextFile(DestUserInput, True, TristateFalse)
ObjFso.WriteLine ReplaceTab
ObjFso.Close

WScript.Sleep 2000

FileExist = Fso.FileExists(DestFile)
If FileExist = True Then
MsgBox Destfile & " was created Successfully."
WScript.Quit
End If

WScript.Quit


How helpful was this article to you?

Related Articles

article How to Find and Replace text within file(s) using MUNGE.exe (NT4 Resource Kit)
Find and Replace text within file(s)...

(No rating)  3-9-2008    Views: 219   
article VB Script to Create a Random File Name
Option Explicit Dim objWshObject,...

(No rating)  3-24-2008    Views: 175   
article VB Script to Create and Write to File
' Create Text file called Temp.txtDim...

(No rating)  3-24-2008    Views: 172   

User Comments

Add Comment
No comments have been posted.