通过outlook保存xlsx附件的自动方式 [英] An automated way to save xlsx attachments through outlook

查看:69
本文介绍了通过outlook保存xlsx附件的自动方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我发现了以下脚本,但我在Set olMi = Fldr.Items(i)的行上遇到运行时错误13类型不匹配感谢您的帮助。 />

Hello,
I found the following script but i get a runtime error 13 type mismatch on the line that says "Set olMi = Fldr.Items(i)" Thanks for your help.

Sub SaveAttachments()

    Dim olApp As Outlook.Application
    Dim olNs As NameSpace
    Dim Fldr As MAPIFolder
    Dim MoveToFldr As MAPIFolder
    Dim olMi As MailItem
    Dim olAtt As Attachment
    Dim MyPath As String
    Dim i As Long

    Set olApp = New Outlook.Application
    Set olNs = olApp.GetNamespace("MAPI")
    Set Fldr = olNs.GetDefaultFolder(olFolderInbox)
    Set MoveToFldr = Fldr.Folders("CompSurv")
    MyPath = "C:\My Documents\Completed Survey\"

    For i = Fldr.Items.Count To 1 Step -1
        Set olMi = Fldr.Items(i)
        If InStr(1, olMi.Subject, "Completed Survey") > 0 Then
            For Each olAtt In olMi.Attachments
                If olAtt.FileName = "Test.xls" Then
                    olAtt.SaveAsFile MyPath & olMi.SenderName & ".xls"
                End If
            Next olAtt
            olMi.Save
            olMi.Move MoveToFldr
        End If
    Next i

    Set olAtt = Nothing
    Set olMi = Nothing
    Set Fldr = Nothing
    Set MoveToFldr = Nothing
    Set olNs = Nothing
    Set olApp = Nothing

End Sub

推荐答案

尝试: Dim olMi As Variant
Try: Dim olMi As Variant


尝试:

Try:
For i = (Fldr.Items.Count-1) To 0 Step -1
       Set olMi = Fldr.Items(i)



类型不匹配意味着返回的对象不匹配你要设置的是什么。



如果上述问题无法解决,请执行JavaScript调试并查看错误发生的时间和时间。尝试环顾四周并进行故障排除。


Type mismatch means that the object returned does not match what you are setting to.

If above does not resolve, do JavaScript debugging and see for what value and when is the error happening. Try to look around that and troubleshoot.


这篇关于通过outlook保存xlsx附件的自动方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆