Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2020, 05:30 AM
macropod's Avatar
macropod macropod is offline Macro to delete tabs in Word Windows 10 Macro to delete tabs in Word Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


The problem appears to be related to the presence of fields in your content. Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "^t"
    .Forward = True
    .Wrap = wdFindStop
  End With
  Do While .Find.Execute = True
    .Start = .Paragraphs(1).Range.Start
    If Len(.Text) - Len(Replace(.Text, vbTab, "")) > 1 Then .Characters.Last.Text = " "
    .Collapse wdCollapseEnd
  Loop
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 12-18-2020, 05:52 AM
Shelley Lou Shelley Lou is offline Macro to delete tabs in Word Windows 10 Macro to delete tabs in Word Office 2016
Expert
Macro to delete tabs in Word
 
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete tabs in Word I need a macro to format images and remove tabs. help LuisXVI Word VBA 4 11-12-2018 03:12 PM
Macro to delete tabs in Word Macro to delete pages in Word 2007 staicumihai Word VBA 4 11-07-2018 01:14 AM
Macro to delete tabs in Word Need Word Macro to Delete Text rsrasc Word VBA 4 04-18-2018 11:32 PM
Tabs set along left edge of page; how to delete ginny Word 4 03-21-2018 08:07 PM
Macro to delete tabs in Word Word Macro to find and delete rows that contain adjacent cells containing "." AlexanderJohnWilley Word VBA 7 11-08-2012 10:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft