Option
Explicit
Sub
CreateAnlage()
Dim
rng
As
Range
Set
rng = Selection.Bookmarks(
"\Page"
).Range
rng.SetRange rng.
End
, rng.
End
rng.
Select
Selection.Orientation = wdTextOrientationVertical
Set
rng =
Nothing
importFromExcel
End
Sub
Sub
importFromExcel()
Dim
exTab
As
Object
Dim
strPath
As
String
Dim
strPath2
As
String
Dim
rngPrintArea
As
Excel.Range
Dim
iRow, iColumn
As
Integer
Dim
einfuegeBereich
As
Range
Dim
WordTable
As
Word.Table
strPath =
"C:\Users\EA.Alici\Documents\TabelleUbersicht2.xlsx"
strPath2 = ActiveDocument.Path &
"\anlagen_excel\20373.xlsx"
Set
exTab = CreateObject(
"excel.application"
)
exTab.workbooks.Open strPath2
exTab.Visible =
True
exTab.Worksheets(
"AnlagenTab"
).Activate
iRow = exTab.Worksheets(1).UsedRange.SpecialCells(xlCellTypeLastCell).Row
iColumn = exTab.Worksheets(1).UsedRange.SpecialCells(xlCellTypeLastCell).Column
exTab.Range(Cells(1, 1), Cells(iRow, iColumn)).
Select
exTab.Range(Cells(1, 1), Cells(iRow, iColumn)).Copy
ActiveDocument.Activate
Selection.Paste
Set
WordTable = ActiveDocument.Tables(1)
WordTable.AutoFitBehavior (wdAutoFitWindow)
End
Sub