Thread: [Solved] Help with Definitions Macro
View Single Post
 
Old 12-10-2020, 10:30 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Your macro does not convert the document to match the result example. They most obvious difference is the example doesn't use tabs whereas the macro inserts them. To get what you wanted and based solely on the provided examples, you need something like.

Code:
Sub DPU_convertdefinitions()
Dim vFindText As Variant
Dim vReplaceText As Variant
Dim i As Integer
    vFindText = Array(Chr(34), Chr(9), Chr(32) & Chr(45), Chr(32) & Chr(44), Chr(32) & Chr(41), Chr(32) & Chr(38))
    vReplaceText = Array("", " ", Chr(45), Chr(44), Chr(41), Chr(38))
    For i = 0 To UBound(vFindText)
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = vFindText(i)
            .Replacement.Text = vReplaceText(i)
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
            .Execute Replace:=wdReplaceAll
        End With
        DoEvents
    Next i
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote