Supportnet / Forum / Tabellenkalkulation
Word-Dokument aus Excel öffnen und drucken
Frage
Ist es möglich, mittels VBA ein bestehendes Word-Dokument aus Excel 7.0 heraus zu öffnen und automatisch zu drucken?
Antwort 1 von Teddy7
Hallo caruso !
Also aus Excel97 heraus ist es möglich.
Folgendes Makro anlegen:
Wichtig ! Zuerst im Makrobild unter Extras->Verweise Mirosoft Word 8.0 Object Library anklicken (oder 9.0 für Word2000) sonst kennt VB Word nicht.
--------------------
Sub Makro5()
Dim objWord As Word.Application
Dim txtDatei As String
txtDatei = Application.InputBox("Worddatei angeben:")
If txtDatei = "" Then
MsgBox "Bitte geben Sie eine zu öffnende Word-Datei an.", vbExclamation
Exit Sub
End If
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open txtDatei
objWord.PrintOut
objWord.Documents.Close
MsgBox "Warten bis Druck beendet - dann Word schließen", vbCritical
objWord.Quit
Set objWord = Nothing
End Sub
--------------------
Gruß
Teddy
Also aus Excel97 heraus ist es möglich.
Folgendes Makro anlegen:
Wichtig ! Zuerst im Makrobild unter Extras->Verweise Mirosoft Word 8.0 Object Library anklicken (oder 9.0 für Word2000) sonst kennt VB Word nicht.
--------------------
Sub Makro5()
Dim objWord As Word.Application
Dim txtDatei As String
txtDatei = Application.InputBox("Worddatei angeben:")
If txtDatei = "" Then
MsgBox "Bitte geben Sie eine zu öffnende Word-Datei an.", vbExclamation
Exit Sub
End If
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open txtDatei
objWord.PrintOut
objWord.Documents.Close
MsgBox "Warten bis Druck beendet - dann Word schließen", vbCritical
objWord.Quit
Set objWord = Nothing
End Sub
--------------------
Gruß
Teddy

