Hallo,
Ich möchte die von mir markierten Zellen (Bsp. "A1-D1") mit einem CommandButton_Click in ein Worddokument einfügen. Mit dem untenstehende Code kann ich leider nur ganz bestimmte Zellen kopieren (A3,B3,C3). Kann mir jemand behilflich sein?
Grazie mille Berni
Private Sub CommandButton1_Click()
Dim wdApp As Object
Dim wdoc As Object
Dim ab As Byte
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
On Error GoTo 0
If wdApp Is Nothing Then
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = True
End If
wdApp.Documents.Add
Set wdoc = wdApp.ActiveDocument
With wdApp.Selection
For ab = 1 To 9
.TypeParagraph
Next
.TypeText Text:=CStr(Range("A3"))
For ab = 1 To 3
.TypeText Text:=vbTab
Next
.TypeText Text:=CStr(Range("B3"))
For ab = 1 To 3
.TypeText Text:=vbTab
Next
.TypeText Text:=CStr(Range("C3"))
End With
wdoc.Paragraphs(9).Range.Font.Bold = True
wdApp.Activate
Set wdoc = Nothing
Set wdApp = Nothing
End Sub
|