通过 Outlook 的 IE 自动化 - 权限被拒绝问题

IE automation via Outlook - Permission Denied issues

Sub test()
    Dim objShell As Object
    Dim objShellWindows As Object
    Dim objWin As Object

    Set objShell = CreateObject("Shell.Application")
    Set objShellWindows = objShell.Windows

    For Each objWin In objShellWindows
        If TypeName(objWin.Document) = "HTMLDocument" Then
            Debug.Print objWin.Document.Location
        End If
    Next objWin 
End Sub

这在 Excel、Access、Word 和 PowerPoint 中工作得很好,但是当从 Outlook 运行 时在 Debug.Print 行抛出 "Run-Time error 70 - Permission Denied" 错误。我正在使用后期绑定来排除引用问题。还检查了 Outlook 宏设置并将它们与其他 Office 应用程序进行了比较——对我来说一切都很好。为什么它在 Outlook 中失败?

试试这个。 returns 与位置相同

Debug.Print objWin.Document.Url

谢谢