Thread: [Solved] Macro to delete tabs in Word
View Single Post
 
Old 12-18-2020, 05:52 AM
Shelley Lou Shelley Lou is offline Windows 10 Office 2016
Expert
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default Macro to delete tabs in Word

Hi Macropod, that seems to have done the trick - with regard to fields, yes there are cross reference fields within some of the definitions. I've just spotted another issue which I wondered if you could help with - in the attached image below - sometimes there will be text under the defined word/text which do not have (a), (b) as sub paras. Is there a way to tell the code to insert a tab before these to be able to then convert into a 2 column table?

insert tab.JPG

Code:
Application.ScreenUpdating = True
      Selection.Find.Execute Replace:=wdReplaceAll
    Dim oRng As Range
Const strText As String = "^13[A-Za-z]"
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=strText, MatchWildcards:=True)
            If oRng.Paragraphs(2).Style = "Normal" And _
               oRng.Paragraphs(2).Range.Characters(1).Font.Bold = False Then
                oRng.Paragraphs(2).Range.InsertBefore vbTab
           End If
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oRng = Nothing
       Exit Sub
Reply With Quote