AW: Exel-Blatt in Word
20.02.2004 11:29:04
AndreasS
Hi,
hier mal ein Makro, ohne Verknüpfungen. Den Button mit dem Makroaufruf mußt du dir halt noch erstellen...
Sub Excel_nach_Word()
Dim WordObj As Object
Dim Bereich As Variant
Dim WordDoc As Object
Dim Extab As Object
Dim i As Integer
Dim x, y As Integer
Sheets("Abgabezettel").Activate
i = ActiveSheet.UsedRange.Rows.Count
Bereich = Range("A1:K" & i).Value
On Error Resume Next
Set WordObj = GetObject(, "Word.Application.9") '9 für 2000, 10 für Version 2003
If Err.Number = 429 Then
Set WordObj = CreateObject("Word.Application.9")
Err.Number = 0
End If
WordObj.Visible = True
Set WordDoc = WordObj.documents.Add
With WordObj.Selection
.typetext Text:="Abgabezettel aus: " & _
ActiveWorkbook.Name
.typeparagraph
.typetext Text:="vom " & Format(Now(), "dd-mm-yy")
.typeparagraph
End With
Set Extab = WordDoc.tables.Add(WordObj.Selection.Range, UBound(Bereich, 1), UBound(Bereich, 2))
With Extab
For x = 1 To UBound(Bereich, 1)
For y = 1 To UBound(Bereich, 2)
.Cells(x, y).Range.insertafter Bereich(x, y)
Next y
Next x
End With
Set WordObj = Nothing
Set WordDoc = Nothing
Set Extab = Nothing
End Sub
Gruß Andreas