我遇到了一個(gè)問(wèn)題,不知道如何解決它,在 Excel VBA 中,我有這個(gè)代碼可以帶我瀏覽一個(gè)網(wǎng)站(https://indexcalculator.ftserussell.com/),但是在我更改網(wǎng)站的第 3 步時(shí)通過(guò) vba 選擇的索引我可以看到它們?cè)诰W(wǎng)頁(yè)上發(fā)生了變化,但是當(dāng)點(diǎn)擊下一頁(yè)按鈕時(shí),它就好像從未被點(diǎn)擊過(guò)一樣。選定的指數(shù)變化:點(diǎn)擊獲取退貨后:months = Format(DateSerial(year(Date), month(Date) - 1, 1), "m") days = Format(DateSerial(year(Date), month(Date), 0), "d") years = CInt(Format(DateSerial(year(Date), month(Date) - 1, 1), "yyyy")) - 1994 Application.Wait (Now + TimeValue("0:00:01")) 'If the year pops up blank that means that the base year is no longer 1994 HTMLdoc.getElementsByName("m_startDate")(0).selectedIndex = CInt(months - 1) HTMLdoc.getElementsByName("d_startDate")(0).selectedIndex = CInt(days - 1) HTMLdoc.getElementsByName("y_startDate")(0).selectedIndex = years Application.Wait (Now + TimeValue("0:00:02")) Set oButton = HTMLdoc.querySelector("a[href='javascript:submitForm(document.forms[0].action);']") oButton.Click Application.Wait (Now + TimeValue("0:00:01")) Set oButton = HTMLdoc.querySelector("a[href='javascript:document.forms[0].target='_blank';submitForm('IndexDownload.aspx');']") oButton.Click第 4 步頁(yè)面應(yīng)該說(shuō)的是 5 月 31 日而不是 6 月 13 日,當(dāng)我手動(dòng)執(zhí)行時(shí),它可以工作。為什么會(huì)發(fā)生這種情況?
.GetElementsByName.SelectedIndex 明顯改變選項(xiàng)但不是以編程方式?
阿晨1998
2021-06-29 15:43:47