How to apply the action to several Outlook items selected?

这一生的挚爱 提交于 2019-12-13 02:33:25

问题


The code here works for one item only. How to modify that to run DisplayItemMetadata (see the code) for each item selected?

Upd. tried to do the following:

For Each individualItem In Application.ActiveExplorer.Selection
    With objButton
        .BeginGroup = True
        .Caption = "My &item"
        .FaceId = 1000
        .Tag = "DisplayItemMetadata"
        If Not IsNull(Selection.Item(1)) Then
            On Error GoTo 0
            ' Just in case the item selected
            ' doesn't have a valid EntryID.
            ' .Parameter = Selection.Item(1).EntryID
            .Parameter = individualItem.EntryID
            On Error GoTo ErrRoutine
        End If
        .OnAction = _
            "Project1.ThisOutlookSession.DisplayItemMetadata"
    End With

Next individualItem

回答1:


You need to iterate over the Selection object, as follows:

Dim individualItem As Object
For Each individualItem In Application.ActiveExplorer.Selection
    'Perform some action on individualItem
Next Message

If you have a function that performs an action on a single selected item, then you should change that function to take a parameter (the item to perform the action on) and then call that function inside the above loop.



来源:https://stackoverflow.com/questions/6385876/how-to-apply-the-action-to-several-outlook-items-selected

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!