Re: Tabellen drehen in VBA

Tech-Archive recommends: Speed Up your PC by fixing your registry




"Wolfram Jahn" schrieb:

So etwa (Word 2007)

Sub dt()
Dim z, s, i_s, i_z
With Tables(1)
z = .Rows.Count
s = .Columns.Count
.Range.Select
End With
Selection.Collapse wdCollapseEnd
With Tables.Add(Selection.Range, s, z)
.AutoFitBehavior wdAutoFitContent
.Borders.InsideLineStyle = wdLineStyleSingle
.Borders.OutsideLineStyle = wdLineStyleSingle
For i_z = 1 To z
For i_s = 1 To s
Tables(1).Cell(i_z, i_s).Range.Copy
.Cell(s - i_s + 1, i_z).Range.Paste
Next i_s
Next i_z
End With
Tables(1).Delete
End Sub

Danke, Wolfram für den Code.
An einigen Stellen hat der VBA-Editor gemotzt; doch jetzt funktioniert er
prima:

Sub dt()
Dim z, s, i_s, i_z
With ActiveDocument.Tables(1)
z = .Rows.Count
s = .Columns.Count
.Range.Select
End With
Selection.Collapse wdCollapseEnd
With ActiveDocument.Tables.Add(Selection.Range, s, z)
.AutoFitBehavior wdAutoFitContent
.Borders.InsideLineStyle = wdLineStyleSingle
.Borders.OutsideLineStyle = wdLineStyleSingle
For i_z = 1 To z
For i_s = 1 To s
ActiveDocument.Tables(1).Cell(i_z, i_s).Range.Copy
.Cell(s - i_s + 1, i_z).Range.Paste
Next i_s
Next i_z
End With
ActiveDocument.Tables(1).Delete
End Sub

Gruß
Ernst


.



Relevant Pages

  • Re: Macro for table problems
    ... You do NOT want to do the macro! ... Dim astyle As Style ... For Each astyle In ActiveDocument.Styles ... .LineStyle = wdLineStyleSingle ...
    (microsoft.public.mac.office.word)
  • Re: Macro for table problems
    ... You do NOT want to do the macro! ... Dim astyle As Style ... For Each astyle In ActiveDocument.Styles ... .LineStyle = wdLineStyleSingle ...
    (microsoft.public.mac.office.word)
  • Re: Macro for table problems
    ... Dim astyle As Style ... For Each astyle In ActiveDocument.Styles ... .Alignment = wdListLevelAlignLeft ... .LineStyle = wdLineStyleSingle ...
    (microsoft.public.mac.office.word)
  • Re: Tabellen drehen in VBA
    ... gibt es in VBA die Möglichkeit, Tabellen sozusagen nach "links" drehen? ... Sub dt ... Dim z, s, i_s, i_z ... .Borders.OutsideLineStyle = wdLineStyleSingle ...
    (microsoft.public.de.word.vba)