[英]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.