![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Here is the situation: I need to insert a large table that will only fit nicely in one page if the page is in the landscape orientation. This creates breakage in my text narrative, because I have to break a section in the middle of a passage. It'd look visually more professional if the text right before the table is flush to the bottom margin of Page x-1, the table appears on page X, and the text picks up again on Page X+1. In order to do this, the whole page in landscape must "float", as a drawing or a frame would float if you anchor it to a certain position in the page.
If this is not possible, can you rotate a table 90 degrees, so that you don't have to start a new section just to create one landscape page? If I can rotate the table 90 degrees counterclockwise, I can frame the entire table and make that frame float. Can you either (a) float a page of different orientation or (b) rotate a table? |
|
#2
|
|||
|
|||
|
You can't have text wrap around a section break which is what you have with a landscape page.
You can have text go in a different direction in a table, though. Tables Here is an example in Word 2010 with the control that does it on the Ribbon.
|
|
#3
|
|||
|
|||
|
Quote:
I've already completed a complex table in the landscape page. Is there an easy way to copy Column 1 to Row 1, Column 2 to Row 2, etc? Otherwise, this will turn into a very laborious copy&paste fest. |
|
#4
|
|||
|
|||
|
If the text in your table does not need to be "live" how about putting your table in a separate document, saving it as an image and rotating it in your document.
|
|
#5
|
|||
|
|||
|
I just gave it a try, and it's barely satisfactory. The resolution is too low, which further gets diminished when I rotate the table imported as an image. Although the table is not "live", I may need to be able to modify it from time to time and it will be a PITA to do the image importing all over again.
|
|
#6
|
||||
|
||||
|
Quote:
The following macro rotates a table, clockwise or counter-clockwise in response to user input, as far as practicable preserving column widths, row heights & text formatting: Code:
Sub RotateTable()
Application.ScreenUpdating = False
Dim i As Long, j As Long, k As Long, x As Long, y As Long, bRotate As Boolean
Dim RngSrc As Range, RngTgt As Range, TblSrc As Table, TblTgt As Table
With Selection
If .Information(wdWithInTable) = True Then
If .Rows.Count > 63 Then
MsgBox "Too many rows - Word only supports up to 63 columns", vbCritical
Exit Sub
End If
Select Case UCase(Left(InputBox("Do you want to rotate the table:" & vbCr & "R = Right (clockwise); or" & vbCr & "L = Left (counter-clockwise)?"), 1))
Case "L": bRotate = True
Case "R": bRotate = False
Case Else: Exit Sub
End Select
Set TblSrc = .Tables(1)
Else
MsgBox vbTab & vbTab & "No Table selected!" & vbCr & _
"Please select some table content before running this macro.", _
vbCritical, "Selection Error"
Exit Sub
End If
End With
With TblSrc
x = .Rows.Count: y = .Columns.Count
With .Range
.Characters.Last.Next.InsertBefore vbCr
.End = .End + 1
End With
End With
Set TblTgt = ActiveDocument.Tables.Add(Range:=TblSrc.Range.Characters.Last.Next, NumRows:=y, NumColumns:=x)
With TblTgt
.Borders = TblSrc.Borders
If bRotate = True Then
For i = 1 To x
For j = 1 To y
Set RngSrc = TblSrc.Cell(i, j).Range: RngSrc.End = RngSrc.End - 1
Set RngTgt = .Cell(j, x - i + 1).Range: RngTgt.End = RngTgt.End - 1
RngTgt.FormattedText = RngSrc.FormattedText
With .Cell(j, x - i + 1)
.BottomPadding = TblSrc.Cell(i, j).RightPadding
.TopPadding = TblSrc.Cell(i, j).LeftPadding
.RightPadding = TblSrc.Cell(i, j).TopPadding
.LeftPadding = TblSrc.Cell(i, j).BottomPadding
End With
Next
Next
On Error Resume Next
For i = 1 To x
.Columns(i).Width = TblSrc.Rows(x - i + 1).Height
If Err.Number = 5149 Then
.Columns(i).AutoFit
Err.Clear
End If
Next
For i = 1 To y
.Rows(i).Height = TblSrc.Columns(i).Width
If Err.Number = 5149 Then
.Rows(i).HeightRule = wdRowHeightAuto
Err.Clear
End If
Next
On Error GoTo 0
.Range.Orientation = wdTextOrientationDownward
ElseIf bRotate = False Then
For i = 1 To x
For j = 1 To y
Set RngSrc = TblSrc.Cell(i, y - j + 1).Range: RngSrc.End = RngSrc.End - 1
Set RngTgt = .Cell(j, i).Range: RngTgt.End = RngTgt.End - 1
RngTgt.FormattedText = RngSrc.FormattedText
With .Cell(j, i)
.BottomPadding = TblSrc.Cell(i, j).LeftPadding
.TopPadding = TblSrc.Cell(i, j).RightPadding
.RightPadding = TblSrc.Cell(i, j).BottomPadding
.LeftPadding = TblSrc.Cell(i, j).TopPadding
End With
Next
Next
On Error Resume Next
For i = 1 To x
.Columns(i).Width = TblSrc.Rows(i).Height
If Err.Number = 5149 Then
.Columns(i).AutoFit
Err.Clear
End If
Next
For i = 1 To y
.Rows(i).Height = TblSrc.Columns(y - i + 1).Width
If Err.Number = 5149 Then
.Rows(i).HeightRule = wdRowHeightAuto
Err.Clear
End If
Next
On Error GoTo 0
.Range.Orientation = wdTextOrientationUpward
End If
End With
TblSrc.Delete
Set RngSrc = Nothing: Set RngTgt = Nothing: Set TblSrc = Nothing: Set TblTgt = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#7
|
|||
|
|||
|
Thanks for this.
I think one of the rows was not fixed in height, and the macro just froze. Is there any way to stop a macro -- in general, not just this macro in particular -- without aborting Word altogether? |
|
#8
|
||||
|
||||
|
Quote:
Ctrl-Break often does the job.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#9
|
|||
|
|||
|
That works! And to think I shut down Word all these years.
As a companion macro to this one, would it be possible to set the row heights and column widths at the current values as "fixed"? Going through each row and column to fix the values was laborious. |
|
#10
|
||||
|
||||
|
Quote:
• rows, that would presumably entail checking the vertical offset of the first character in each cell on the current row against the vertical offset of the first character in each cell on the next row or, if it's the last row in the table, the next paragraph. • columns, one would have to compare the relative horizontal offsets of the, say, first character in each cell - ensuring their paragraph formatting had 0 left indent and left/justified alignment. That's because, if the height or width is not set to an 'exact' or 'at least' value (rows only), retrieving it returns a meaningless 99999. And an 'at least' value can't be turned into a meaningful column width, as columns don't have an 'at least' parameter and the 'at least' value may not be the actual value.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Page Orientation Format Problem | dawnwriter | Word | 3 | 05-14-2013 11:57 AM |
| Page borders vs Orientation | Ineedcoffee | Word | 5 | 12-06-2011 12:52 PM |
Rotate Page and Content Within It.
|
walker140 | Word | 1 | 11-13-2011 11:08 PM |
Changing page orientation within a section
|
el rebelde | Word | 3 | 10-11-2011 01:12 AM |
| Page Orientation | bubbelytoes | Word | 1 | 09-06-2006 12:41 PM |