'замена "шаблонов" (ключевых слов) в документе ворда, на значения из списка
'ключ хэша - "шаблон", значение - замена
Function ReplaceByTemplate(replacementList List As String, worddoc As Variant) As Boolean
On Error GoTo ErrorHandler
Dim wObj As Variant
Dim rngToSearch As Variant
Dim rngResult As Variant
Dim i As Long
Dim s As String, txt As String
Set wObj = worddoc.Application
Set rngToSearch = worddoc.Content
ForAll m In replacementList
Set rngResult = rngToSearch.Duplicate
' s=defDelim.GetEscLeft() & Listtag(m) & defDelim.GetEscRight()
' s={\<} & Listtag(m) & {\>}
s=ListTag(m)
rngResult.Find.Text = s
rngResult.Find.Forward = True
rngResult.Find.Wrap = wdFindStop
'не действует MachCase=False для шаблона \<fld_name\>
rngResult.Find.MatchCase = False'MSWord - индусское поделие
' rngResult.Find.MatchWholeWord = False
rngResult.Find.MatchWildcards = True
txt=CStr(m)
rngResult.Find.Replacement.Text=txt
rngResult.Find.Execute ,,,,,,,,,,wdReplaceAll
' Do While rngResult.Find.Execute()
' i = i + 1
' rngResult.Select
' worddoc.Application.Selection.Text=m
' rngResult.Collapse 0 'wdCollapseEnd
' Loop
i=i+1
DbgMsg({Значение:} & ListTag(m) & ", #" & CStr(i))
End ForAll
ReplaceByTemplate=True
ExitFunctoin:
Exit Function
ErrorHandler:
Call RaiseError()
Print {#} & Format(i, {000000}) & { ;replace value>} & s & { ;by value>} & txt
Resume ExitFunctoin
End Function