Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 08-04-2019, 10:30 PM
Guessed's Avatar
Guessed Guessed is offline Macro to remove table captions leaves empty space Windows 10 Macro to remove table captions leaves empty space Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You will need a second bite at it if the caption is followed by a table since the paragraph mark remains if the paragraph contains any content.
Code:
Sub delTableCaptionAll()
  Dim ctr As Integer, aRng As Range
  Set aRng = ActiveDocument.Range
  With aRng.Find
    .Text = "Table"
    .ClearFormatting
    .Style = "Caption"
    .Forward = True
    Do While .Execute
      aRng.Paragraphs(1).Range.Delete
      If aRng.Paragraphs(1).Next.Range.Information(wdWithInTable) Then
        aRng.Delete
      End If
      ctr = ctr + 1
    Loop
    Debug.Print ctr
  End With
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove space between header and first bullet in Outlook email created by Excel macro kevinbradley57 Excel Programming 1 03-27-2019 08:39 PM
Macro to remove table captions leaves empty space How to remove almost a full page of blank space in between Word table rows garrisonsdad Word Tables 4 10-18-2018 09:09 PM
Macro to remove table captions leaves empty space Can't get rid of empty white space in table wtfword Word Tables 2 01-24-2018 02:47 AM
Macro to remove table captions leaves empty space Remove consecutive empty paragraphs within existing macro kevinbradley57 Word VBA 5 10-11-2017 05:04 PM
Macro to remove table captions leaves empty space Remove space after table in header melliejane Word 1 03-05-2012 04:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:04 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