尝试在 VBA 中获取 URL 时遇到问题,当使用 IE 版本 8 的“访问 ie 2003”中的自动化时。代码运行良好,它到达语句: artRSSFeed = .Document.Url 记住之前的 URL 分配( FeedURL = .Document.Url) 在浏览器的同一实例中返回正常,并且在浏览器中到达第二个 .navigate 下的 URL。错误是:运行时错误“445”对象不支持此操作!
感谢任何帮助表示赞赏。
'Process artRSSPostLink in order to get feed name, Source permalink and RSS Feed
Set ie2 = CreateObject("InternetExplorer.Application")
With ie2
' Disable pop-up msgs
.Silent = True
.Navigate artRSSPostlink
Do While .ReadyState <> 4 Or ie.Busy = True
DoEvents
Loop
If Err Then .Quit Else .Visible = True
'The point of this is that the Postlink is often not hosted at the feed URL or even on the same server (feeddemon for instance) consequentally it is redirected
Dim FeedURL As String
FeedURL = .Document.Url
artSourcePostPermalink = FeedURL
'Dim artSource As String
artSource = Left(FeedURL, InStr(8, FeedURL, "/") - 1)
artSource = Right(artSource, Len(artSource) - 7) 'strip "http://"
'Me!artSource = artSource
'enter the domain/feed url to see if there is a redirect for the feed
.Navigate "http://" & artSource & "/feed"
Do While .ReadyState <> 4 Or ie.Busy = True
DoEvents
Loop
artRSSFeed = .Document.Url
End With