Tags erzeugen ...
Erstellen Sie ein Excel-Makro, um Blätter als PDF mit dem Namen der Blätter zu extrahieren
Fortschritt
Antwort
Sicherlich! Unten sehen Sie ein Excel-VBA-Makro, das jedes Blatt in der Arbeitsmappe als PDF-Datei mit dem Namen des Blatts extrahiert:
- Öffnen Sie Ihre Excel-Arbeitsmappe.
- Drücken Sie
Alt + F11
, um den VBA-Editor zu öffnen. - Fügen Sie ein neues Modul ein, indem Sie auf
Insert > Module
klicken. - Kopieren Sie den folgenden Code und fügen Sie ihn in das Modul ein:
Sub ExportSheetsAsPDF() Dim ws As Worksheet Dim filePath As String Dim fileName As String Dim fullPath As String ' Set the path to save the PDFs (modify as needed) filePath = ThisWorkbook.Path & "\" For Each ws In ThisWorkbook.Worksheets ' Create the full path and file name fileName = ws.Name & ".pdf" fullPath = filePath & fileName ' Export the sheet as a PDF ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fullPath, Quality:=xlQualityStandard, _ IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False Next ws ' Notify user that sheets have been exported MsgBox "All sheets have been exported as PDFs to " & filePath, vbInformation End Sub
- Schließen Sie den VBA-Editor.
- Führen Sie das Makro aus, indem Sie
Alt + F8
drücken,ExportSheetsAsPDF
auswählen und aufRun
klicken.
Dieses Makro exportiert jedes Blatt in Ihrer Excel-Arbeitsmappe als separate PDF-Datei mit dem Namen des Blatts, die im selben Verzeichnis wie die Arbeitsmappe gespeichert ist. Ändern Sie die Variable filePath
, wenn Sie die PDFs in einem anderen Verzeichnis speichern möchten.
Vorschläge
- Wie öffne ich den VBA-Editor in Excel?
- Wozu dient das Makro "ExportSheetsAsPDF" in Excel VBA?
- Wie ändere ich den Dateipfad zum Speichern von PDFs im Excel VBA-Makro?
- Welche Parameter werden in der Methode "ExportAsFixedFormat" in Excel VBA verwendet?
- Wie führe ich ein Makro in Excel mit Tastenkombinationen aus?
AAAnonymous