有人可以帮我解决这个我试图在VBA中实现的小脚本吗?
附加内容是循环随机停止,我无法移动“archivio”文件夹中的所有邮件。
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
答案 0 :(得分:1)
根据问题的评论,新的循环可能看起来像(未经测试)
Dim i As Long
For i = specCartella.Items.Count to 1 Step -1
specCartella.Items(i).Move olDestFolder
Next i
(我刚刚用i改变了x!)