IE automation via Outlook - Permission Denied issues

怎甘沉沦 提交于 2019-12-13 03:54:18

问题


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

This works perfectly fine in Excel, Access, Word and PowerPoint, but throws "Run-Time error 70 - Permission Denied" error on the Debug.Print line when ran from Outlook. I'm using late binding to rule out references issues. Also went through Outlook macro settings and compared them with the other Office apps - all seems fine to me. Why is it failing in Outlook?


回答1:


try this. returns same as Location

Debug.Print objWin.Document.Url

thanks



来源:https://stackoverflow.com/questions/50926529/ie-automation-via-outlook-permission-denied-issues

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