0

有人可以帮我解决我试图在 VBA 中实现的这个小脚本吗?

附加的是循环随机停止,我无法移动“存档”文件夹中的所有邮件。

Private Sub aggiorna_click()

    Dim x As Object
    Dim ns As Outlook.NameSpace
    Dim itm, sgsa, actionPlan, cartella, specCartella As Object
    Dim olDestFolder As Outlook.MAPIFolder

    Set ns = GetNamespace("MAPI")
    Set itm = ns.GetDefaultFolder(olFolderInbox)
    Set sgsa = itm.Folders("SGSA")
    Set actionPlan = sgsa.Folders("action plan")
    Set cartella = actionPlan.Folders(tipo.Text)
    Set specCartella = cartella.Folders(piano.Text)

Set olDestFolder = itm.Folders("archivio")
For Each x In specCartella.Items
    x.Move olDestFolder
Next x

End Sub
4

1 回答 1

1

根据问题下的评论,新循环可能看起来像这样(未经测试)

Dim i As Long
For i = specCartella.Items.Count to 1 Step -1
    specCartella.Items(i).Move olDestFolder
Next i

(我刚刚用 i 改变了 x!)

于 2013-04-04T19:25:16.820 回答