通过VBA更改网站的活动选择

时间:2014-04-01 12:53:23

标签: excel-vba vba excel

我试图通过Excel模块将VBA代码中页面中显示的产品限制从“15”更改为“全部”。

<fieldset class="results-per-page">
 <span> 
    <label>Results per page</label>
    <a href="#15" id="15" class="active">15</a>
    <a href="#30" id="30" >30</a>
    <a href="#all" id="all">View All</a>
 </span>
</fieldset> 

2 个答案:

答案 0 :(得分:1)

为什么不直接导航到那个?例如ie.navigate sURL & "#all"?其中sURL是上页的网址...

参见此示例

Sub sample()
    Dim ie As Object
    Dim sURL As String

    '~~> Change this to the relevant URL
    sURL = "D:\Users\SidzPc\Desktop\test.htm"

    Set ie = CreateObject("internetexplorer.application")
    ie.Visible = True

    ie.navigate sURL & "#all"
End Sub

<强>截图

enter image description here

答案 1 :(得分:0)

谢谢,我找到了解决方案,

这是代码 -

      If IE.Document.Links.Length > 0 Then

For i = 1 To 600
        If IE.Document.Links(i) = "http://www.xyz.com/computer/all-products#all" Then
           IE.Document.Links(i).Click
        End If
Next i

       End If