参考

2016-08-25 108 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