Hallo,
ich bin noch ziemlich neu im Umgang mit VBA und habe bisher mit Textmarken gearbeitet. Jetzt möchte ich eine Tabelle in die Fußzeile einfügen um in die jwl. Spalten dann dynamischen Inhalt einfügen zu können (wenn das angeklickt wurde, dann bitte das einfügen usw.). Doch ich scheitere an der Tabelle in der Fußzeile. Ich bekomme einfach nicht den Befehl heraus dass die Fußzeile angesprochen wird. Ich wäre wirklich dankbar, wenn mir jemand helfen könnte.
Vielen Dank.
1. Meine Tabelle wird eingefügt
2. Meine Tabelle soll eigentlich in die Fußzeile
ich bin noch ziemlich neu im Umgang mit VBA und habe bisher mit Textmarken gearbeitet. Jetzt möchte ich eine Tabelle in die Fußzeile einfügen um in die jwl. Spalten dann dynamischen Inhalt einfügen zu können (wenn das angeklickt wurde, dann bitte das einfügen usw.). Doch ich scheitere an der Tabelle in der Fußzeile. Ich bekomme einfach nicht den Befehl heraus dass die Fußzeile angesprochen wird. Ich wäre wirklich dankbar, wenn mir jemand helfen könnte.
Vielen Dank.
1. Meine Tabelle wird eingefügt
2. Meine Tabelle soll eigentlich in die Fußzeile
Visual Basic-Quellcode
- Sub FußzeilenTabelleEinfügen()
- Dim Bereich As Range
- Dim Tabelle As Table
- Set Bereich = ActiveDocument.Range(Start:=0, End:=0)
- Set Tabelle = ActiveDocument.Tables.Add _
- (Range:=Bereich, NumRows:=3, NumColumns:=3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
- wdAutoFitFixed)
- With Selection.Tables(1)
- If .Style <> "Tabellenraster" Then
- .Style = "Tabellenraster"
- End If
- End With
- Selection.EndKey Unit:=wdLine, Extend:=wdExtend
- Selection.EndKey Unit:=wdLine, Extend:=wdExtend
- Selection.EndKey Unit:=wdLine, Extend:=wdExtend
- Selection.EndKey Unit:=wdLine, Extend:=wdExtend
- Selection.EndKey Unit:=wdLine, Extend:=wdExtend
- Selection.EndKey Unit:=wdLine, Extend:=wdExtend
- Selection.EndKey Unit:=wdLine, Extend:=wdExtend
- Selection.EndKey Unit:=wdLine, Extend:=wdExtend
- Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
- Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
- Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
- Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
- Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
- Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
- Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
- Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
- With Selection.Borders(wdBorderRight)
- .LineStyle = Options.DefaultBorderLineStyle
- .LineWidth = Options.DefaultBorderLineWidth
- .Color = Options.DefaultBorderColor
- End With
- Selection.MoveLeft Unit:=wdCharacter, Count:=1
- With Selection.Borders(wdBorderRight)
- .LineStyle = Options.DefaultBorderLineStyle
- .LineWidth = Options.DefaultBorderLineWidth
- .Color = Options.DefaultBorderColor
- End With
- Selection.MoveDown Unit:=wdLine, Count:=1
- With Selection.Borders(wdBorderRight)
- .LineStyle = Options.DefaultBorderLineStyle
- .LineWidth = Options.DefaultBorderLineWidth
- .Color = Options.DefaultBorderColor
- End With
- Selection.MoveDown Unit:=wdLine, Count:=1
- With Selection.Borders(wdBorderRight)
- .LineStyle = Options.DefaultBorderLineStyle
- .LineWidth = Options.DefaultBorderLineWidth
- .Color = Options.DefaultBorderColor
- End With
- Selection.MoveRight Unit:=wdCharacter, Count:=1
- With Selection.Borders(wdBorderRight)
- .LineStyle = Options.DefaultBorderLineStyle
- .LineWidth = Options.DefaultBorderLineWidth
- .Color = Options.DefaultBorderColor
- End With
- Selection.MoveUp Unit:=wdLine, Count:=1
- With Selection.Borders(wdBorderRight)
- .LineStyle = Options.DefaultBorderLineStyle
- .LineWidth = Options.DefaultBorderLineWidth
- .Color = Options.DefaultBorderColor
- End With
- Selection.MoveUp Unit:=wdLine, Count:=1
- With Selection.Borders(wdBorderRight)
- .LineStyle = Options.DefaultBorderLineStyle
- .LineWidth = Options.DefaultBorderLineWidth
- .Color = Options.DefaultBorderColor
- End With
- End Sub
Visual Basic-Quellcode
- Sub Test1()
- With ActiveDocument.Sections(1).Footers(1)
- .Range.Select
- With Selection
- Set Table = ActiveDocument.Tables.Add _
- (Range:=Range, NumRows:=3, NumColumns:=3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
- With Selection.Tables(1)
- If .Style <> "Tabellenraster" Then
- .Style = "Tabellenraster"
- End If
- End With
- End With
- End With
- End Sub