leider muß ich Euch nochmal nerven :)
Folgendes, ich will von einem Arbeitsblatt (Bild1) den Druckbereich (Bild2) speichern als "Speicher unter" und Wahl des Formats (pdf, word etc). Natürlich mit den Rahmen also Format...
Sozusagen nur die Inventurliste...über den Button oben links (Speichern) startbar
Mein bisheriger Code ist:
Sub ExportPrintAreaToWord()
Dim WordApp As Object
Dim WordDoc As Object
Dim ExcelRange As Range
Dim PrintArea As String
Dim Ws As Worksheet
' Set worksheet
Set Ws = ThisWorkbook.Sheets("Inventur") ' Ändern Sie den Blattnamen entsprechend
' Get the print area
PrintArea = Ws.PageSetup.PrintArea
If PrintArea = "" Then
MsgBox "Druckbereich ist nicht definiert!"
Exit Sub
End If
' Set the range to the print area
Set ExcelRange = Ws.Range(PrintArea)
' Create a new Word Application
On Error Resume Next
Set WordApp = GetObject(Class:="Word.Application")
If WordApp Is Nothing Then
Set WordApp = CreateObject(Class:="Word.Application")
End If
On Error GoTo 0
' Make Word visible
WordApp.Visible = True
' Add a new document
Set WordDoc = WordApp.Documents.Add
' Copy the range from Excel
ExcelRange.Copy
' Paste the range into the Word document
WordDoc.Content.Paste
' Save the Word document
Dim WordFilePath As String
WordFilePath = Application.GetSaveAsFilename(FileFilter:="alle dateien (*.pdf), *.pdf", Title:="Speichern als")
If WordFilePath > "False" Then
WordDoc.SaveAs2 Filename:=WordFilePath, FileFormat:=16 ' wdFormatXMLDocument = 20 for .doc
MsgBox "Druckbereich erfolgreich in Word gespeichert!", vbInformation
Else
MsgBox "Speichern abgebrochen", vbExclamation
End If
' Cleanup
WordDoc.Close False
WordApp.Quit
Set WordDoc = Nothing
Set WordApp = Nothing
Set ExcelRange = Nothing
End Sub
Aber es führt leider nicht zum Erfolg :(


Hat jemand ne Idee??