Hallo zusammen,
im unten stehenden Makro wird eine Tabelle mit einem Feld erstellt, um Bilder in einen Bericht einzufügen. Das Ganze gibt es auch als 2er Tabelle. Ziel ist es eben, dass immer alles gleich aussieht.
Ich würde gerne eine zweite Zeile darunter eröffnen (NumRows:=2), deren Formatierung wie folgt ist:
- Keine Rahmenlinie unten, links und rechts
-Schirftgröße 9, kursiv, zentriert, Myriad Pro (Formatvorlage: "Bildbeschriftung").
Ist das relativ leicht umsetzbar?
Sub Tabelle1er()
'
' Tabelle1er Makro
'
'
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "Tabellenraster" Then
.Style = "Tabellenraster"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
End With
With Selection.Tables(1)
.TopPadding = CentimetersToPoints(0)
.BottomPadding = CentimetersToPoints(0)
.LeftPadding = CentimetersToPoints(0.19)
.RightPadding = CentimetersToPoints(0.19)
.Spacing = 0
.AllowPageBreaks = True
.AllowAutoFit = False
End With
With Selection.Cells(1)
.WordWrap = False
.FitText = False
End With
Selection.Range.Cells(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Range.Cells(1).PreferredWidth = CentimetersToPoints(7.3)
With Selection.Tables(1)
.TopPadding = CentimetersToPoints(0)
.BottomPadding = CentimetersToPoints(0)
.LeftPadding = CentimetersToPoints(0.19)
.RightPadding = CentimetersToPoints(0.19)
.Spacing = 0
.AllowPageBreaks = True
.AllowAutoFit = False
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
Selection.Tables(1).Rows.HeightRule = wdRowHeightAtLeast
Selection.Tables(1).Rows.Height = CentimetersToPoints(5.4)
Selection.Tables(1).Rows.AllowBreakAcrossPages = False
Selection.Range.Cells(1).VerticalAlignment = wdCellAlignVerticalCenter
Selection.Tables(1).Select
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
End Sub
Der Vollständigkeit halber hier noch die 2er Tabellenvariation:
Sub Tabelle2er()
'
' Tabelle2er Makro
'
'
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _
3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
With Selection.Tables(1)
If .Style <> "Tabellenraster" Then
.Style = "Tabellenraster"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
End With
Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
Selection.Tables(1).Rows.HeightRule = wdRowHeightExactly
Selection.Tables(1).Rows.Height = CentimetersToPoints(5.4)
Selection.Tables(1).Rows.AllowBreakAcrossPages = False
Selection.Tables(1).Columns(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Tables(1).Columns(1).PreferredWidth = CentimetersToPoints(7.3)
Selection.Range.Cells(1).VerticalAlignment = wdCellAlignVerticalCenter
Selection.Range.Cells(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Range.Cells(1).PreferredWidth = CentimetersToPoints(7.3)
Selection.MoveRight Unit:=wdCell
Selection.Tables(1).Columns(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Tables(1).Columns(1).PreferredWidth = CentimetersToPoints(1)
Selection.Range.Cells(1).VerticalAlignment = wdCellAlignVerticalCenter
Selection.Range.Cells(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Range.Cells(1).PreferredWidth = CentimetersToPoints(1)
Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
Selection.MoveLeft Unit:=wdCell
With Selection.Borders(wdBorderTop)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderLeft)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderBottom)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderRight)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.Tables(1).Columns(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Tables(1).Columns(1).PreferredWidth = CentimetersToPoints(7.3)
Selection.Range.Cells(1).VerticalAlignment = wdCellAlignVerticalCenter
Selection.Range.Cells(1).PreferredWidthType = wdPreferredWidthPoints
Selection.Range.Cells(1).PreferredWidth = CentimetersToPoints(7.3)
With Selection.Borders(wdBorderTop)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderLeft)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderBottom)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Borders(wdBorderRight)
.LineStyle = Options.DefaultBorderLineStyle
.LineWidth = Options.DefaultBorderLineWidth
.Color = Options.DefaultBorderColor
End With
With Selection.Tables(1)
.TopPadding = CentimetersToPoints(0)
.BottomPadding = CentimetersToPoints(0)
.LeftPadding = CentimetersToPoints(0.19)
.RightPadding = CentimetersToPoints(0.19)
.Spacing = 0
.AllowPageBreaks = True
.AllowAutoFit = False
End With
With Selection.Cells(1)
.WordWrap = False
.FitText = False
End With
Selection.Tables(1).Select
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
End Sub
Vielen Dank im Voraus!
|