将所选项目更改为下一个或上一个 [英] Change the selected item to next or previous

查看:81
本文介绍了将所选项目更改为下一个或上一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面编写了与

I wrote code below that is very similar to the accepted answer here. It marks emails and meeting responses as read and moves them to the archive.

我按最新的邮件排序.使用宏后,选择默认为下一封电子邮件(较旧的电子邮件).我希望它移至下一封电子邮件(较新的一封).如果我颠倒了电子邮件的排序顺序,那么它将按我希望的那样工作.我为此花费了太多时间,只是为了反转电子邮件的排序顺序.

I sort my mail by newest on top. After using the macro, the selection defaults to the next email down (the older one). I want it to move to the next email up (the newer one). If I reverse the sorting order of emails, then it works how I want it to. I've dedicated too much time to this to just reverse the sorting order of my emails.

我试图将MailItem设置为Application.ActiveExplorer.CurrentFolder.Items.GetNext,然后使用MailItem.Display.这是打开而不是更改选择,它不知道当前选择,无法弄清楚什么是下一个".

I tried to set a MailItem to Application.ActiveExplorer.CurrentFolder.Items.GetNext then use MailItem.Display. This opens rather than changes selection, doesn't know current selection, can't figure out what's considered "next".

我尝试设置Application.ActiveExplorer.Selection.Item属性.我一直在(MSDN和Expert sexchange )寻求解决方案.

I tried setting the Application.ActiveExplorer.Selection.Item property. I've been through (MSDN and Expertsexchange) looking for a solution.

Sub MoveToArchive()
    On Error Resume Next
    Dim objFolder As Outlook.MAPIFolder
    Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem
    Dim objMRItem As Outlook.MeetingItem
    Set objNS = Application.GetNamespace("MAPI")
    Set objFolder = objNS.Folders("Archive").Folders("Inbox")

    If Application.ActiveExplorer.Selection.Count = 0 Then
        Exit Sub
    End If

    For Each objItem In Application.ActiveExplorer.Selection
        If objFolder.DefaultItemType = olMailItem Then
            If objItem.Class = olMail Then
                objItem.UnRead = False
                objItem.Move objFolder
            End If
        End If
    Next

    For Each objMRItem In Application.ActiveExplorer.Selection
        If objFolder.DefaultItemType = olMailItem Then
            If objItem.Class = olMeetingResponsePositive Or olMeetingResponseNegative Or olMeetingResponseTentative Then
                objMRItem.UnRead = False
                objMRItem.Move objFolder
            End If
        End If
    Next

    Set objItem = Nothing
    Set objMRItem = Nothing
    Set objFolder = Nothing
    Set objNS = Nothing
End Sub

推荐答案

Outlook无法以编程方式在资源管理器"窗口中选择特定项目. 因此,您将可以通过这种方式进行操作.我认为您可以执行此操作的唯一方法是以编程方式按工具栏或菜单上的上一个键.或重新启动该应用以将其存档在检查器中,等等.

Outlook provides no way to programmatically select a particular item in the Explorer window. So you would be able to do it this way. The only way I think that you could do it would be to programmatically press the previous key on the tool bar or menu. or redesgin the app to archive in the inspector etc.

这篇关于将所选项目更改为下一个或上一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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