【发布时间】:2026-02-13 22:00:01
【问题描述】:
我有一个 Sub 可以打开当前打开的邮件项的文件夹。
如果我打开了一个项目,但更改了中间的邮件文件夹,并且想立即再次打开正确的文件夹,这是有意义的。
Sub ordner_mail_oeffnen()
On Error GoTo exit_sub
'Dim olApp As Outlook.Application
Dim olitem As Outlook.mailitem
'Set olApp = Outlook.Application
Set olitem = Outlook.Application.ActiveInspector.CurrentItem
Dim olfolder As MAPIFolder
Dim FolderPath As String
Dim Subfolder As Outlook.MAPIFolder
FolderPath = GetPath(olitem)
Set olfolder = GetFolder(FolderPath)
olfolder.Display
'those two lines are just for test purpose
MsgBox "jetzt"
Application.ActiveExplorer.ClearSelection
Sleep (10000)
Application.ActiveExplorer.ClearSelection
'here comes the runtime-error (I try to translate) "-2147467259 (80004005) element can not be activated or deactivated, as id does not exist in the current view"
Application.ActiveExplorer.AddToSelection olitem
exit_sub:
exit_sub:
End Sub
只有在出现错误后,新文件夹才会打开,但不会选择某些邮件。
【问题讨论】: