是否有另存为对话框?
我想使用“另存为”文件对话框保存邮件附件。是否可以使用 VBA 和 Outlook 来完成此操作?
I want to save a mail attachment with a SaveAs
file dialog. Is it possible to do this with VBA and Outlook?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为 Outlook 不会让您打开文件对话框!
我使用的一个丑陋但快速且实用的解决方法是临时打开 Excel 实例并使用其
GetSaveAsFilename
方法。然后你可以说
MyAttachment.SaveAsFile(strSaveAsFilename)
。如果不一定安装 Excel,那么您可以使用 Word 和 FileDialog 方法执行类似的操作(Word 没有 GetSaveAsFilename)。有关示例,请参阅 FileDialog 上的 VBA 帮助。
可能有一个更优雅的解决方案,但上面的方法可以工作......
I don't think Outlook will let you open a file dialog!
An ugly but quick and functional workaround that I have used is to temporarily open an instance of Excel and use its
GetSaveAsFilename
method.Then you can say
MyAttachment.SaveAsFile(strSaveAsFilename)
.If Excel is not necessarily installed, then you can do a similar trick using Word and the FileDialog method (Word doesn't have GetSaveAsFilename). See VBA help on FileDialog for an example.
There is probably a more elegant solution out there, but the above will work...
不要忘记 BrowseForFolder 函数:
Don't forget the
BrowseForFolder
function:有两种方法可以模拟此行为(此处假设为 Outlook 2003):
使用文件 » 保存附件
此代码将以编程方式调用“文件”菜单上的“保存附件”菜单项。以下三个辅助功能是必需的,应粘贴到同一个项目中。选择或打开带有附件的电子邮件,然后运行
SaveAttachments
过程。请注意,如果有多个附件,系统将提示您选择要保存的附件,然后再显示保存对话框:
使用 BrowseForFolder
我使用 上找到的 BrowseForFolder 函数VBAX。这将显示 Shell.Application 的 BrowseForFolder 对话框:
选择或打开带有附件的电子邮件并运行 < code>SaveAttachments 过程。在对话框中选择文件夹后,电子邮件的所有附件都将保存到所选文件夹中。
There are two ways to simulate this behavior (I assume Outlook 2003 here):
Use File » Save Attachments
This code will programmatically call the "Save Attachments" menu item on the File Menu. The three ancillary functions below are necessary and should be pasted into the same project. Select or open an email with attachments and run the
SaveAttachments
procedure.Note that if there are multiple attachments, you will be prompted to choose which one(s) you want to save before being shown the save dialog:
Use BrowseForFolder
I use the BrowseForFolder function found on VBAX. This will show the Shell.Application's BrowseForFolder dialog:
Select or open an email with attachments and run the
SaveAttachments
procedure. After selecting a folder in the dialog, all attachments to the email will be saved to the selected folder.