Hi
Am having code of batch replacing strings and getting error for char more than 250, can any one help to fix this issue...
My code is shown below:
Code
Public Sub batchReplace_test()
Dim Directory As String
Dim FType As String
Dim FName As String
Directory = InputBox("PLEASE ENTER PATH", "SELECT THE TARGET FOLDER") & "\"
FType = "*.docx"
ChDir Directory
FName = Dir(FType)
' for each file you find, run this loop
Do While FName <> ""
' open the file
Documents.Open FileName:=FName
' search and replace the company name
Selection.find.ClearFormatting
Selection.find.Replacement.ClearFormatting
Selection.find.Replacement.Font.Bold = True
Selection.find.Replacement.Font.Color = wdColorRed
With Selection.find
.Text = "OldCompanyName"
.MatchCase = True
.Replacement.Text = "NewCompanyName"
End With
Selection.find.Execute Replace:=wdReplaceAll
' replace street address
With Selection.find
.Text = "OldStreetAddress"
.Replacement.Text = "NewStreetAddress"
End With
Selection.find.Execute Replace:=wdReplaceAll
' replace the comment
' With Selection.find
' .Text = "Government subsidies that are included in the current profit and loss, but are closely related to the company's normal business operations, except for government subsidies that meet national policy requirements and are continuously enjoyed by a fixed amount or amount according to a certain standard"
' .Replacement.Text = "Government subsidy accounted as gain or loss for the period, other than those closely related to the company's normal business operations, complying with the national policy, and continuing to be enjoyed at a fixed rate or amount"
' End With
' Selection.find.Execute Replace:=wdReplaceAll
' save and close the current document
ActiveDocument.Close wdSaveChanges
' look for next matching file
FName = Dir
Loop
End Sub
Display More
Thanks in advance ....