A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Working with a nesting table from inside a nested table - switchingrows.

Thread Tools Display Modes
Old December 8th 09, 12:03 PM posted to microsoft.public.word.tables
external usenet poster
Posts: 12
Default Working with a nesting table from inside a nested table - switchingrows.

Imagine you have a table, and nested in each cell is a table. Your
selection is inside one of the nested tables. You want to switch the
row containing your selected table with the row above it. What makes
this a bit tricky is that (it seems) you can't directly identify the
nesting (exterior) cell/row/table.

Below FWIW is the code I came up with. It seems to work fine, but I'm
hoping/expecting there's a more elegant and robust way to do it.

[An additional constraint I was working with was that if your nested
table is already in the top row of the nesting table, it should seem
to the user as if nothing at all happened; e.g. the cursor should stay
in the same spot. Hence the NestingRowIndex function.]

Sub MoveRowUp()
Dim DeleteMe As Row
If NestingRowIndex 1 Then
Selection.Expand wdTable
Selection.Collapse wdCollapseEnd
Selection.MoveEnd wdCharacter
Set DeleteMe = Selection.Rows(1)
Selection.Expand wdRow
MsgBox ("You're at the top already.")
End If

End Sub

Function NestingRowIndex()
'You're in a nested table. What is the row number of cell in which
the table is nested?
Dim testRange As Range
Set testRange = Selection.Range
testRange.Expand wdTable
testRange.Collapse wdCollapseEnd
testRange.MoveEnd wdCharacter
NestingRowIndex = testRange.Cells(1).RowIndex
End Function

PS my approach was based on a suggestion by Cindy Meister,

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2003 "paste as nested table" not nesting [email protected] Tables 0 August 14th 07 11:42 PM
Enter inside table moves the table Monika Bjurman Tables 4 July 10th 07 04:56 PM
Creating a table inside an existing table Eric Schmieder Tables 2 October 13th 05 05:45 PM
Drawing a table inside of a table Luc New Users 1 August 23rd 05 10:43 AM
How can I draw a table inside of a table? avinoam.aharoni New Users 5 June 29th 05 07:12 PM

All times are GMT +1. The time now is 06:46 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright 2004-2019 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.