![]() |
|
#1
|
||||
|
||||
![]() 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] |
#2
|
|||
|
|||
![]()
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 |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
LuisXVI | Word VBA | 4 | 11-12-2018 03:12 PM |
![]() |
staicumihai | Word VBA | 4 | 11-07-2018 01:14 AM |
![]() |
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 |
![]() |
AlexanderJohnWilley | Word VBA | 7 | 11-08-2012 10:15 AM |