Option
Explicit
Sub
ExportRangeToWord()
Dim
wksQuellTabelle
As
Excel.Worksheet
Dim
rngBereich
As
Excel.Range
Dim
docDokument
As
Object
Dim
appWord
As
Object
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