none
How to Check One table is getting overlapped with already existing table in Word

    Question

  • Hi,

    Can anyone tell How to know One table is getting overlapped with another table(existing table) while inserting.

    Assume I have already inserted Table1 and while inserting Table2, It is getting Overlapped with table1, But Code wise after inserting Table2,Is there any way to check Table2 is Overlapping/Overridden on Table1
    Otherwise

    How to identify The table is getting overlapped with the Footer line of the page? suppose,at a particular paragraph,i have inserted one table(Left aligned ,Text Wrapped) ,since sufficient space is not there,it is getting inserted there only ,crossing Footer line of the page.So by seeing that,we get to know that table got inserted on the Footer Line,but code wise,how to identify this Scenario?

    Wednesday, December 12, 2012 12:09 PM

Answers

  • Perhaps it would be better to not use text wrapping in the first place. That way, you can better control issues of overlapping.

    You can use code like the following to test the table's size & position, plus whether it overlaps one of the margins:

    Sub Test()
    Dim i As Long, lTop As Long, lHght As Long, lLeft As Long, lWdth As Long
    With ActiveDocument.ActiveWindow.Panes(1).Pages(1)
      For i = 1 To .Rectangles.Count
        With .Rectangles(i)
          If .Range.Tables.Count > 0 Then
            lTop = .Top: lLeft = .Left: lHght = .Height: lWdth = .Width
            With .Range.Sections(1).PageSetup
              If lTop < .TopMargin Then MsgBox "Overlap with Top Margin"
              If (lTop + lHght) > (.PageHeight - .BottomMargin) Then MsgBox "Overlap with Bottom Margin"
              If lLeft < .LeftMargin Then MsgBox "Overlap with Left Margin"
              If (lLeft + lWdth) > (.PageWidth - .RightMargin) Then MsgBox "Overlap with Right Margin"
            End With
          End If
        End With
      Next
    End With
    End Sub


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, December 13, 2012 1:36 AM