0
我試圖從Internet Explorer窗口返回pageYOffset值。 在我的VBA編輯器中的本地窗口中,我可以清楚地看到該值,但是當我嘗試使用VBA檢索它時,出現運行時錯誤'438':對象不支持此屬性或方法。在excel-VBA中獲取Internet Explorer窗口屬性(pageYOffset)
這裏是我的代碼的簡化版本:
Sub getProperty()
Dim IEWindow As New InternetExplorer
Dim scrollValue as Long
Set IEWindow = New InternetExplorer
IEWindow.Visible = True
IEWindow.navigate "www.somewebsite.com", TargetFrameName:="_parent"
Sleep 1000
'Scrolls to very bottom of page (approximate)
IEWindow.document.parentWindow.Scroll 0, 5000
'Retrieves the exact scroll value
scrollValue = IEWindow.document.parentWindow.pageYOffset
End Sub
我已經沖刷網頁尋找答案,但沒有VBA相關似乎表明了這讓我想起我找錯了地方。
就像一個魅力@Ambie。非常感謝!這是一件奇怪的事情,你必須明確定義每個對象。但是,如果它的工作,它的作品! – TheGuyOverThere