View Single Post
 
Old 09-02-2018, 02:52 PM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Here is what I tried after including the If test, but I get a "Compile Error: Method or data member not found"

It debugs to - .Text

I'm I right on thinking the [3-4] should be changed to [3] if I'm starting with Attachment 3 as the beginning point?

Code:
Sub Add_Rows_Table()
    Application.ScreenUpdating = False
    Dim Tbl As Table, Rng As Range
    For Each Tbl In ActiveDocument.Tables
        With Tbl
            If .Range.Characters.First.Previous.Paragraphs.Last.Text Like "Attachment [3]" & vbCr Then
                .Rows.Add
                Set Rng = .Range
                .Range.Cells(.Range.Cells.Count).Range.InsertBreak Type:=wdColumnBreak
                Rng.Tables(2).Range.Cells.Merge
                .Range.Characters.First.Previous.InsertBefore vbCr
                .Range.Characters.First.Previous.Previous.FormattedText = Rng.Tables(2).Range.FormattedText
                Rng.Tables(2).Delete
                .Range.Characters.First.Previous.Delete
                .Range.Characters.Last.Next.Delete
            End If
        End With
    Next Tbl
    Set Rng = Nothing
    Application.ScreenUpdating = True
End Sub
Reply With Quote