![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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.
|
|
#2
|
|||
|
|||
|
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. |
|
#3
|
||||
|
||||
|
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] |
|
#4
|
|||
|
|||
|
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? |
|
#5
|
||||
|
||||
|
Quote:
Ctrl-Break often does the job.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#6
|
|||
|
|||
|
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. |
|
|
|
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 |