[英]Saving an excel xlsm file in an outlook email
I need help saving an excel xlsm file from an outlook email using excel VBA. I need help saving an excel xlsm file from an outlook email using excel VBA.
Im modifying an excel VBA that extracts data from lab reports on a server.我正在修改从服务器上的实验室报告中提取数据的 excel VBA。
I want to add the function where the latest lab report is saved from my email to the server.我想添加 function,其中最新的实验室报告从我的 email 保存到服务器。
I've got the code below, but i get an error saying outlook cannot perferom this action on this type of attachment.我有下面的代码,但我收到一条错误消息,提示 outlook 无法对此类附件执行此操作。 The type being xlsm.
类型为 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
Is there a work around for this?有解决办法吗?
Thanks,谢谢,
What kind of attachment is it?它是一种什么样的依恋? Make sure it is
Attachment.Type == olByValue
(1).确保它是
Attachment.Type == olByValue
(1)。 Outlook cannot save embedded OLE attachments ( olOle
== 6), you'd need Redemption for that if you are using VBA. Outlook 无法保存嵌入式 OLE 附件(
olOle
== 6),如果您使用的是 VBA,则需要兑换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.