[英]Saving an excel xlsm file in an outlook email
I need help saving an excel xlsm file from an outlook email using excel VBA.
我正在修改从服务器上的实验室报告中提取数据的 excel VBA。
我想添加 function,其中最新的实验室报告从我的 email 保存到服务器。
我有下面的代码,但我收到一条错误消息,提示 outlook 无法对此类附件执行此操作。 类型为 xlsm。
Sub Getlabreport()
Dim O As Outlook.Application
Set O = New Outlook.Application
Dim ONS As Outlook.Namespace
Set ONS = O.GetNamespace("MAPI")
Dim ORIG_FOL As Outlook.Folder
Set ORIG_FOL = ONS.GetDefaultFolder(olFolderInbox)
For Each Item In ORIG_FOL.Items
For Each Atmt In Item.Attachments
If Atmt.FileName = Range("Lab_file").Value Then
FileName = Range("Save_folder").Value & "\" & Atmt.FileName
Atmt.SaveAsFile FileName
Exit Sub
End If
Next Atmt
Next Item
End Sub
有解决办法吗?
谢谢,
它是一种什么样的依恋? 确保它是Attachment.Type == olByValue
(1)。 Outlook 无法保存嵌入式 OLE 附件( olOle
== 6),如果您使用的是 VBA,则需要兑换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.