如何在Outlook上使用msoFileDialogFolderPicker或类似工具

我想运行一个宏,该宏使我可以在每次要选择的文件夹中对Outlook附件进行分类。基本上,我想以一种简单的方式在不同的文件夹中分配不同的客户订单。

我已经尝试过了,但是它一直显示“错误438”。我猜想msoFileDialogFolderPicker在Outlook中的工作方式与在Excel中不同。谢谢您的帮助!

Public Sub ADJUNTOS2()

Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim strFile As String
Dim strFolderpath As String
Dim strDeletedFiles As String


With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Elige carpeta"
.ButtonName = "Confirmar"
.InitialFileName = "C:\"
If .Show = -1 Then
strFolderpath = .SelectedItems(1)
Else
End If
End With

On Error Resume Next

Set objOL = CreateObject("Outlook.Application")


Set objSelection = objOL.activeExplorer.Selection
strFolderpath = strFolderpath


For Each objMsg In objSelection

Set objAttachments = objMsg.Attachments
lngCount = objAttachments.Count

If lngCount > 0 Then

For i = lngCount To 1 Step -1


strFile = objAttachments.Item(i).FileName


strFile = strFolderpath & strFile


objAttachments.Item(i).SaveAsFile strFile

Next i
End If

Next

ExitSub:

Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub
qianjun8u8 回答:如何在Outlook上使用msoFileDialogFolderPicker或类似工具

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2550781.html

大家都在问