Written by Allen Wyatt (last updated May 1, 2020)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365
Ray wonders if there is a way to move an entire Word table vertically, pixel by pixel. Everything he has read indicates that grabbing it and holding the Alt key will allow for that, but it does not work smoothly.
I'm not sure where Ray has been reading, but the Alt key does not allow for nudging tables. In fact, it doesn't seem to work for table movement at all, with one exception—if you press Shift+Alt and then use the up or down arrow keys, the table is moved up or down an entire paragraph in your document.
Other keystroke combinations don't work either. You would think that nudging tables would work as it does for other objects within a document—you select the object and then use the arrow keys to give the nudge. However, it doesn't work with tables at all. If you select the table and then press the up or down arrow keys, then Word deselects the table and moves the insertion point either above or below the table in the document.
There are a couple of workarounds you can use, however. First, you could adjust how you put your tables in the document. Simply put them within a text box, and then you can use the arrow keys to nudge the text box. (You can also format the border on the text box so it doesn't show.)
Another workaround is to use a macro to do the movement. The following macro will move the table a single pixel up:
Sub MoveTableUp1() ' set pxl to the number of pixels to move: positive for down and ' negative for up Const pxl As Single = -1 If Not Selection.Information(wdWithInTable) Then Exit Sub With Selection.Tables(1) .Rows.VerticalPosition = .Rows.VerticalPosition + PixelsToPoints(pxl) End With End Sub
All you need to do is make sure that the insertion point is within the table you want to nudge. If you want to move the table down instead of up, simply change the definition of the pxl constant to be a positive 1 instead of a negative 1.
There is something else you should note about this macro—it may mess up your document layout. You see, the VerticalPosition property is only effective if your table is configured to allow text to wrap around it. (This is configured in the Table Wrapping area of the Table Properties dialog box.) Recognizing this, when you use the macro to adjust the VerticalPosition property, it automatically changes the table from "none" to "around." This, obviously, could affect the page layout if you didn't previously have wrapping turned on and the table is narrower than your text area.
There is another potential "gotcha" here, as well. You might think that you can adjust the horizontal position of the table by changing the VerticalPosition property in the above macro to HorizontalPosition. This seems logical, but how it works in the macro may throw you for a loop. Where adjusting the VerticalPosition property will change the table wrapping from "none" to "around," adjusting the HorizontalPosition property will not. Instead, on some versions of Word, it will give you an error.
The safest way to deal with all of these quirks is to adjust the macro to make sure that it only adjusts a table if its wrapping property is set to True, in this manner:
Sub MoveTableUp2() Dim sTemp As String ' set pxl to the number of pixels to move: positive for down and ' negative for up Const pxl As Single = -1 sTemp = "" If Selection.Information(wdWithInTable) Then With Selection.Tables(1).Rows If .WrapAroundText Then .VerticalPosition = .VerticalPosition + PixelsToPoints(pxl) Else sTemp = "Table is inline. No action taken." End If End With Else sTemp = "The insertion point is not within a table. No action taken." End If If sTemp > "" Then MsgBox sTemp End Sub
This variation of the macro also includes a bit more feedback for the user so that if no action is taken, the user is told why this is the case.
If you prefer, you can move the table a point (1/72 of an inch) at a time. Here's the version of the macro that could handle this movement:
Sub MoveTableUp3() Dim sTemp As String ' set pt to the number of points to move: positive for down and ' negative for up Const pt As Single = -1 sTemp = "" If Selection.Information(wdWithInTable) Then With Selection.Tables(1).Rows If .WrapAroundText Then .VerticalPosition = .VerticalPosition + pt Else sTemp = "Table is inline. No action taken." End If End With Else sTemp = "The insertion point is not within a table. No action taken." End If If sTemp > "" Then MsgBox sTemp End Sub
As already discussed, nudging the table horizontally instead of vertically is simply of matter of using the HorizontalPosition property with the Rows object rather than the VerticalPosition property. Remember, though, the caveats discussed, as well, as to how the HorizontalPosition property differs in use from the VerticalPosition property. With this in mind, you could rather easily create four versions of your macro (for each of the four directions you might want to nudge your table) and then assign shortcut keys to the macros.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12136) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
Need to adjust the space between individual cells in a table? Word gives you a good deal of control over this spacing, as ...
Discover MoreWant to see the exact height of a row? This tip provides a quick and precise way that you can see that height.
Discover MoreWhen you insert a table into your document, it uses a standard-weight line around each cell in the table. If you want to ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2018-08-11 07:25:37
Al Wilson
Sorry, but for me this macro does not work. Well, at least works in a strange way. The Macro for moving Up and Down actually move my table left and right, whereas my modified version using HosizontalPosition causes an error 9118 Parameter value was out of accepted range. This was when using pxl parameter as either 1 or -1. Basically no change to the macro other than changing VerticalPosition to HorizontalPosition.
Can't understand the issue unless it thinks my document is in Landscape mode (It is in portrait) but that would not explain the 9118 error.
I assume HorizontalPosition can be incremented or decremented by a Single of either 1 or -1?
Edit. Up and Down work correctly but using HorizontalPosition causes the error 9118. I am using Word 2016.
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments