Leren hoe om PDF-bijlagen van Microsoft Outlook met behulp van Visual Basic for Applications ( VBA ) kunt u tijd besparen wanneer u nodig hebt om een groot aantal PDF-bijlagen af te drukken . VBA is een programmeertaal die wordt gebruikt in alle Microsoft Office-toepassingen om taken zoals het afdrukken van bestanden te automatiseren . In Outlook kunt u procedures waar VBA-code wordt toegevoegd en uitgevoerd met behulp van de VB -editor te creëren . Gebruik de " ShellExecute " bibliotheek om de printopdracht uit te voeren en afdrukken van een PDF -bestand . U kunt een paar "For ... Loops " te creëren om te zoeken naar PDF-bijlagen in uw inbox map en print ze . Instructies Lancering Microsoft Outlook 1 , klikt u op het menu "Extra " en klik op " Macro > Visual Basic Editor " om de VB -editor ramen open . Klik op het menu "Invoegen " en klik op "Module " om een nieuwe VBA-code -module toe te voegen . Copy 2 en plak de volgende code om de functie " ShellExecute " te definiëren die je zal gebruiken om de PDF af te drukken bestanden: Public Declare Function ShellExecute Lib " shell32.dll " Alias " ShellExecuteA " _ ( ByVal hWnd zoals lang, ByVal lpOperation als Koord , ByVal lpFile als Koord , _ByVal lpParameters als Koord , ByVal lpDirectory als Koord , _ByVal nShowCmd als lang) als Long 3 Voeg de volgende functie om de functie " ShellExecute " noemen en print de huidige PDF -bestand : functie PrintFile ( pdfName Zoals string) ShellExecute 0 , "Afdrukken" , pdfName , vbNullString , " " , 1End Function Kopieer 4 en plak de onderstaande code om lus door alle poststukken en alle PDF-bijlagen gevonden afdrukken met uw standaard printer : . Public Sub PrintAttachments ( ) Dim myInbox Zoals MAPIFolderDim MailItem Zoals mailItemDim attchmt Zoals AttachmentDim pdfName Zoals StringSet myInbox = GetNamespace ( " MAPI " ) GetDefaultFolder ( olFolderInbox ) voor Elke MailItem In myInbox.ItemsFor elke attchmt In mailItem.AttachmentsIf ( InStr ( 1 , attchmt , " pdf . " , vbTextCompare ) < > 0 ) ThenpdfName = " C : \\ Temp \\ " & attchmt.fileNameattchmt.SaveAsFile pdfNameCall PrintFile ( pdfName ) eindigen IfNextNextSet myInbox = NothingEnd Sub Druk " F5 " 5 om de code uit te voeren . De code zal alle PDF-bijlagen in te slaan " C : \\ Temp " voordat u ze afdrukt . |