![]() |
#1
|
|||
|
|||
![]()
Hi,
I need help on a little piece of code. I have a document made of multiples tables with titles between them. I would like to delete one line above each title to reduce the space between each table. The title is not in the table as I've converted them to text before. Any help would be appreciated... Thanks ![]() Edit: all the titles contains a same word. Last edited by Dzib; 09-10-2019 at 11:21 AM. |
#2
|
|||
|
|||
![]() Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim lngIndex As Long Dim oRng As Range For lngIndex = ActiveDocument.Tables.Count To 2 Step -1 Set oRng = ActiveDocument.Tables(lngIndex).Range oRng.Collapse wdCollapseStart oRng.Move wdParagraph, -1 'By your description, the range should now be defined at the table title. If Not oRng.Paragraphs(1).SpaceBefore = 0 Then oRng.Paragraphs(1).SpaceBefore = 0 If Len(oRng.Paragraphs(1).Previous.Range) = 1 And Not _ oRng.Paragraphs(1).Previous.Range.Information(wdWithInTable) Then oRng.Paragraphs(1).Previous.Range.Delete End If Next lbl_Exit: Exit Sub End Sub |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ljg713 | Word VBA | 1 | 12-21-2015 04:27 PM |
Microsoft Word macro to find text, select all text between brackets, and delete | helal1990 | Word VBA | 4 | 02-05-2015 03:52 PM |
![]() |
konopca | Word VBA | 2 | 06-07-2012 02:44 AM |
![]() |
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
![]() |
simpleonline1234 | Word VBA | 1 | 02-25-2011 02:28 AM |