ich möchte gerne aus Excel heraus in Word eine kleine Wordtabelle erstellen.
Die Tabelle soll 2 Spalten und 2 Zeilen haben.
In der ersten Zeile soll in jede Spalte ein Text rein der Fett sein soll.
Kann mir jemand helfen?
Danke im Voraus.
Sub wordCreateTable()
Dim objWord As Object, objDoc As Object, rng As Object
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("E:\Forum\Test.docx")
With objDoc
Set rng = .Paragraphs.Add(.Paragraphs(.Paragraphs.Count).Range)
.Tables.Add Range:=rng.Range, NumRows:=2, NumColumns:=2
With .Tables(.Tables.Count)
.Borders.Enable = True
.Cell(1, 1).Range.Text = "Datum"
.Cell(1, 2).Range.Text = "Text"
.Rows(1).Range.Font.Bold = True
End With
End With
objWord.Visible = True
Set objDoc = Nothing
Set objWord = Nothing
End Sub
Sub wordCreateTable()
Dim objWord As Object, objDoc As Object, rng As Object
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("E:\Forum\Test.docx")
With objDoc
.Range.Collapse 0
.Range.InsertParagraphAfter
Set rng = .Paragraphs.Add(.Paragraphs(.Paragraphs.Count).Range)
.Tables.Add Range:=rng.Range, NumRows:=2, NumColumns:=2
With .Tables(.Tables.Count)
.Borders.Enable = True
.Cell(1, 1).Range.Text = "Datum"
.Cell(1, 2).Range.Text = "Text"
.Rows(1).Range.Font.Bold = True
.Columns(1).Width = 45
.Columns(2).Width = 75
End With
End With
objWord.Visible = True
Set objDoc = Nothing
Set objWord = Nothing
End Sub