选中网页上的复选框

时间:2018-04-26 06:55:28

标签: html vba

Web page interface

Code for the first image

大家好, 我需要选中第一张图片中显示的网页上的框,并且ID方法的get元素在这种情况下不起作用:ie.document.getElementById("exportFormatGrids_excelFormattingGridsIServer").Click

我该如何勾选方框?此外,在第二个图像中是“Excel with formatting”框的代码

我使用的完整代码是:

    Dim ie As Object
Dim objClass As Object
Dim ObjPage As Object
Dim objButton As Object

Dim ThsWb As Workbook
Dim ThsSh As Worksheet

Set ThbWs = ThisWorkbook
Set ThSh = ThbWs.Sheets("TgsUmsRep")

Dim RepLnk As String
Dim StrDate As String
Dim EndDate As String

RepLnk = ThSh.Range("D9")
StrDate = ThSh.Range("D11")
EndDate = ThSh.Range("D12")


   Set ie = New InternetExplorerMedium
       ie.Visible = True
         ie.Navigate2 RepLnk   'RepLnk = https://mis.lidl.net/MicroStrategy/servlet/mstrWeb?Server=L-MIS03&Project=MIS+International&Port=0&evt=4001&src=mstrWeb.4001&visMode=0&reportViewMode=1&reportID=9E1E8C7111E700DF00000080EFA5F88E&reportSubtype=768

         Do While ie.Busy
            Application.Wait DateAdd("s", 1, Now)
         Loop

delay 3
ie.document.getElementById("id_mstr39_txt").Value = StrDate

delay 3
ie.document.getElementById("id_mstr46_txt").Value = EndDate

delay 3
ie.document.getElementById("id_mstr64").Click

delay 3
ie.document.getElementById("tbExport").Click

delay 3
ie.document.getElementById("exportFormatGrids_excelFormattingGridsIServer").Click    'This is where I get to the part that the pictures show and where the problem is

提前谢谢!

1 个答案:

答案 0 :(得分:0)

尝试使用属性checked

ie.document.getElementById("exportFormatGrids_excelFormattingGridsIServer").checked = true;