參考

2016-08-25 49 views
0

我發現了以下Outlook VBA腳本,批處理打印所有電子郵件附件中的子文件夾的收件箱中的子文件夾:參考

Public Sub PrintAttachments() 
Dim Inbox As MAPIFolder 
Dim Item As MailItem 
Dim Atmt As Attachment 
Dim FileName As String 
Dim i As Integer 

Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders.Item("Batch Prints") 

For Each Item In Inbox.Items 
    For Each Atmt In Item.Attachments 
     ' all attachments are first saved in the temp folder C:\Temp. Be sure to create this folder. 
     FileName = "C:\Temp\" & Atmt.FileName 
     Atmt.SaveAsFile FileName 
     ' please change the program folder accordingly if the Acrobat Reader is not installed on drive C: 
     Shell """C:\Program Files\Adobe\Reader 8.0\Reader\acrord32.exe"" /h /p """ + FileName + """", vbHide 
    Next 

    Item.Delete 'remove this line if you don't want the email to be deleted automatically 
Next 

Set Inbox = Nothing 
End Sub 

來源:http://www.howtogeek.com/howto/microsoft-office/batch-print-pdf-attachments-in-outlook/

我的問題是:是否有可能將此腳本轉換爲64位,因爲安裝32位Office不是一個選項。

我發現PtrSafe,但只有在涉及到.dll聲明時纔有意義。

Office版本2016的64位

+1

會發生什麼事,當你64位的Outlook中運行呢?一般來說,香草VBA應該可以在32/64版本之間移植。 –

+0

有趣。我收到以下錯誤:「運行時錯誤'-2147221233(8004010f)':嘗試的操作失敗。找不到對象。在調試器中,它突出顯示: Set Inbox = GetNamespace(」MAPI「)。 GetDefaultFolder(olFolderInbox).Parent.Folders.Item(「Batch Prints」)'我已經驗證了批量打印子文件夾以及Temp文件夾的存在 – Spagett

+1

「批量打印」與「收件箱「?你開始使用收件箱,然後上到父PST文件,然後下到」批量打印「。這是正確的嗎? –

回答

0

是,如果你的文件夾的子文件夾,那麼你的代碼設置爲

Set Inbox = GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders.("Batch Prints") 

如果是多個子目錄下,那麼

Folders.("Folder name").Folders.("Batch Prints") 

要在64位Outlook中使用宏,您需要添加PtrSafe來聲明:

Compatibility Between the 32-bit and 64-bit Versions of Office 2010