Tabelle in Fußzeile mittels VBA

  • Word

    Tabelle in Fußzeile mittels VBA

    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

    Visual Basic-Quellcode

    1. Sub FußzeilenTabelleEinfügen()
    2. Dim Bereich As Range
    3. Dim Tabelle As Table
    4. Set Bereich = ActiveDocument.Range(Start:=0, End:=0)
    5. Set Tabelle = ActiveDocument.Tables.Add _
    6. (Range:=Bereich, NumRows:=3, NumColumns:=3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
    7. wdAutoFitFixed)
    8. With Selection.Tables(1)
    9. If .Style <> "Tabellenraster" Then
    10. .Style = "Tabellenraster"
    11. End If
    12. End With
    13. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    14. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    15. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    16. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    17. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    18. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    19. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    20. Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    21. Selection.Borders(wdBorderTop).LineStyle = wdLineStyleNone
    22. Selection.Borders(wdBorderLeft).LineStyle = wdLineStyleNone
    23. Selection.Borders(wdBorderBottom).LineStyle = wdLineStyleNone
    24. Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone
    25. Selection.Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone
    26. Selection.Borders(wdBorderVertical).LineStyle = wdLineStyleNone
    27. Selection.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
    28. Selection.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
    29. With Selection.Borders(wdBorderRight)
    30. .LineStyle = Options.DefaultBorderLineStyle
    31. .LineWidth = Options.DefaultBorderLineWidth
    32. .Color = Options.DefaultBorderColor
    33. End With
    34. Selection.MoveLeft Unit:=wdCharacter, Count:=1
    35. With Selection.Borders(wdBorderRight)
    36. .LineStyle = Options.DefaultBorderLineStyle
    37. .LineWidth = Options.DefaultBorderLineWidth
    38. .Color = Options.DefaultBorderColor
    39. End With
    40. Selection.MoveDown Unit:=wdLine, Count:=1
    41. With Selection.Borders(wdBorderRight)
    42. .LineStyle = Options.DefaultBorderLineStyle
    43. .LineWidth = Options.DefaultBorderLineWidth
    44. .Color = Options.DefaultBorderColor
    45. End With
    46. Selection.MoveDown Unit:=wdLine, Count:=1
    47. With Selection.Borders(wdBorderRight)
    48. .LineStyle = Options.DefaultBorderLineStyle
    49. .LineWidth = Options.DefaultBorderLineWidth
    50. .Color = Options.DefaultBorderColor
    51. End With
    52. Selection.MoveRight Unit:=wdCharacter, Count:=1
    53. With Selection.Borders(wdBorderRight)
    54. .LineStyle = Options.DefaultBorderLineStyle
    55. .LineWidth = Options.DefaultBorderLineWidth
    56. .Color = Options.DefaultBorderColor
    57. End With
    58. Selection.MoveUp Unit:=wdLine, Count:=1
    59. With Selection.Borders(wdBorderRight)
    60. .LineStyle = Options.DefaultBorderLineStyle
    61. .LineWidth = Options.DefaultBorderLineWidth
    62. .Color = Options.DefaultBorderColor
    63. End With
    64. Selection.MoveUp Unit:=wdLine, Count:=1
    65. With Selection.Borders(wdBorderRight)
    66. .LineStyle = Options.DefaultBorderLineStyle
    67. .LineWidth = Options.DefaultBorderLineWidth
    68. .Color = Options.DefaultBorderColor
    69. End With
    70. End Sub


    Visual Basic-Quellcode

    1. Sub Test1()
    2. With ActiveDocument.Sections(1).Footers(1)
    3. .Range.Select
    4. With Selection
    5. Set Table = ActiveDocument.Tables.Add _
    6. (Range:=Range, NumRows:=3, NumColumns:=3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed)
    7. With Selection.Tables(1)
    8. If .Style <> "Tabellenraster" Then
    9. .Style = "Tabellenraster"
    10. End If
    11. End With
    12. End With
    13. End With
    14. End Sub