View Single Post
 
Old 02-19-2024, 06:43 AM
syl3786 syl3786 is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Jan 2023
Posts: 97
syl3786 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
Bearing in mind that there are no 'pages' in a Word document, if your selected range is in a table. then the following is an example of code to move the selection before the table.
Code:
 Dim orng As Range
 Dim oTable As Table
    Set orng = Selection.Range
    If orng.Information(wdWithInTable) = True Then
        Set oTable = orng.Tables(1)
        orng.Start = oTable.Range.Start
        orng.Collapse 1
        orng.Select
        Selection.SplitTable
        Set orng = Selection.Range
        orng.Text = "The selection is before the table"
    Else
        orng.Text = "The selection is not in a table"
    End If
Thank you so much for your invaluable assistance! It's truly a pleasure to be in the presence of someone as skilled in VBA as yourself!
Reply With Quote