Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub TextReplace()
- Dim wdDoc As Object
- Dim oRng As Object
- Dim placeholderNames(0) As String
- Dim placeholderValues(0) As String
- Dim name As String
- Dim value As String
- Dim index As Integer
- Dim i As Integer
- On Error GoTo ErrHandler
- placeholderNames(0) = "[[ИНН]]"
- placeholderValues(0) = "1234567890"
- If TypeName(ActiveWindow) = "Inspector" Then
- If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then
- Set wdDoc = ActiveInspector.WordEditor
- Set oRng = wdDoc.Range
- With oRng.Find
- For i = LBound(placeholderNames) To UBound(placeholderNames)
- name = placeholderNames(i)
- value = placeholderValues(i)
- Do While .Execute(findText:=name)
- oRng.Text = value
- oRng.collapse 0
- Loop
- Next i
- End With
- End If
- End If
- lbl_Exit:
- Exit Sub
- ErrHandler:
- Beep
- Resume lbl_Exit
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement