View Single Post
 
Old 08-04-2019, 08:38 PM
afif afif is offline Windows 7 64bit Office 2010
Novice
 
Join Date: Jul 2019
Posts: 16
afif is on a distinguished road
Default Macro to remove table captions leaves empty space

I tried to run the macro to remove captions in all tables in a document.

Code:
Sub delTableCaptionAll()
    
    
    Dim ctr As Integer
    Dim txt As String
    Dim Check As Boolean
    Dim para As Paragraph
    ctr = 0
    
    
    
    For Each para In ActiveDocument.Paragraphs
        txt = para.Range.Text
        Debug.Print txt
        
        Check = InStr(txt, "Table")
        Debug.Print Check
        
        If Check = True And para.Range.Style = "Caption" Then
            para.Range.Delete
        End If
        ctr = ctr + 1
        Debug.Print ctr
    Next
End Sub
The problem is it doesn't remove the line (image attached) after the caption is deleted. How can I remove the space after the caption is deleted ?
Thanks
Attached Images
File Type: png space.png (1.3 KB, 13 views)
Reply With Quote