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
行上抛出“运行时错误70 - 权限被拒绝”错误。我正在使用后期绑定来排除引用问题。还浏览了Outlook宏设置并将它们与其他Office应用程序进行了比较 - 对我来说似乎都很好。为什么在Outlook中失败?
答案 0 :(得分:1)
尝试一下。返回与位置相同
Debug.Print objWin.Document.Url
谢谢