Gruppe
Extern
Problem
Der Bereich A1:C1 soll in ein Word-Dokument eingelesen und von dort gedruckt werden. Die Aktion soll im Hintergrund ablaufen.
StandardModule: Modul1
Sub PrintWord()
Dim wdApp As Object
Dim wdDoc As Object
Dim sFile As String
sFile = Range("F1").Value
If Dir(sFile) = "" Then
Beep
MsgBox "Datei wurde nicht gefunden!"
Else
Set wdApp = CreateObject("Word.Application")
wdApp.Visible = False
Set wdDoc = wdApp.Documents.Open(sFile)
Range("A1:C1").Copy
wdDoc.Range.Paste
wdDoc.PrintOut
Application.Wait Now + TimeSerial(0, 0, 5)
wdDoc.Close savechanges:=False
wdApp.Quit
Set wdDoc = Nothing
Set wdApp = Nothing
Application.CutCopyMode = False
End If
End Sub