Sub
ExportRangeToWord()
Dim
wksQuellTabelle
As
Worksheet
Dim
rngBereich
As
Range
Dim
docDokument
As
Word.Document
Dim
appWord
As
Word.Application
Set
wksQuellTabelle = ActiveWorkbook.Worksheets(
"Stromkosten"
)
Set
rngBereich = wksQuellTabelle.UsedRange
Set
appWord = CreateObject(
"Word.Application"
)
Set
docDokument = appWord.Documents.Add()
appWord.Visible =
True
rngBereich.Copy
docDokument.Paragraphs(1).Range.PasteExcelTable
True
,
False
,
False
docDokument.SaveAs2 Backslash(ThisWorkbook.Path) & wksQuellTabelle.Name &
".docx"
Application.CutCopyMode =
False
If
appWord.Documents.Count > 1
Then
docDokument.Close
Else
appWord.Quit
End
If
Set
wksQuellTabelle =
Nothing
Set
rngBereich =
Nothing
Set
docDokument =
Nothing
Set
appWord =
Nothing
End
Sub