Dim MyPath As String
Dim FileLoop As Long
Dim MyString As String
Dim MyFile As String
Dim MyLen As Long
Dim MyFind As String
Dim MyReplace As String
Dim MyCopy As String
Dim MyLenCheck As Double
Dim MyCounter As Long
Private Sub Form_Load()
MyPath = "C:\My Documents\Webpage" 'Ur path
File1.Path = MyPath'Set the path of the file list box
File1.Pattern = "*.htm"'And type of files
FileLoop = File1.ListCount'How many files
MyCounter = 0
File1.ListIndex = MyCounter
End Sub
Private Sub Command1_Click()
File1.ListIndex = MyCounter
MyFile = MyPath & "\" & File1.List(MyCounter)
MyLen = FileLen(MyFile)
'Open the applicable page
Open MyFile For Input As #1
MyString = Input(MyLen, #1)
Close #1
'What u want to change
MyFind = "string to change from"
MyReplace = "string to change to"
'Replace 'find' with 'replace'
MyCopy = Replace(MyString, MyFind, MyReplace)
'Check to see that any items were found
MyLenCheck = (Len(MyCopy) - Len(MyString)) / (Len(MyReplace) - Len(MyFind))
Label1 = MyLenCheck
Command2.SetFocus
End Sub
Private Sub Command2_Click()
'Write the changed page back
Open MyFile For Output As #1
Print #1, MyCopy
Close #1
MyCounter = MyCounter + 1
Command1.SetFocus
If MyCounter >= FileLoop Then Command2.Enabled = False
End Sub