Vor einiger Zeit fragte ich um ein Makro, das mir in Excel markierte
Zellen ins Word kopiert. Ich erhielt das Makro der Anlage. Es funktioniert
wunderbar (ich möchte mich dafür nochmal bedanken).
Meine Frage ist die Folgende:
Nach dem Einfügen ins Word steht der Cusor am Ende der letzen eingefügten Zeile.
Ist es irgendwie möglich dieses Makro so zu erweitern, dass nach dem Einfügen
ins Word "automatisch" Enter gedrückt wird und so der Cursor eine neue leere
Zeile beginnt (Ich hoffe das war verständlich...).
Schöne Grüße und besten Dank
Andreas
Sub KopiereinsWord()
Dim rg As Range
Set rg = Application.Selection
If rg Is Nothing Then
MsgBox "..."
Exit Sub
End If
rg.Copy
Set rg = Nothing
Dim oApp As Word.Application
Set oApp = GetApplication("Word.Application")
If oApp Is Nothing Then
MsgBox "..."
Exit Sub
End If
Dim oDoc As Word.Document
Set oDoc = oApp.ActiveDocument
oApp.Selection.PasteAndFormat wdFormatPlainText
Set oDoc = Nothing
Set oApp = Nothing
End Sub
Function GetApplication(ByVal AppClass As String) As Object
Const vbErr_AppNotRun = 429
On Error Resume Next
Set GetApplication = GetObject(Class:=AppClass)
If Err.Number = vbErr_AppNotRun _
Then Set GetApplication = CreateObject(AppClass)
On Error GoTo 0
End Function