单击带有VBA的网页上的按钮

时间:2016-05-12 06:54:09

标签: vba

我是VBA的初学者。我正在尝试使用VBA单击网页上的“刷新”按钮。但我不能这样做。

你能支持我吗?谢谢大家

HTML

刷新“type =”submit“> 刷新

2 个答案:

答案 0 :(得分:1)

尝试使用以下

    public static ApiResponse uploadFileToServer(){
    File file = new File("your asset path");
    Map<String, Object> dataParams = new HashMap<String, Object>();
    data.put("name", <file_name>);
    data.put("file", file);
    //here type and name are necessary to create entity
    data.put("type", <collection_name>);
    data.put("name", <entity_name>);
    //entity_name will be the name of your new created entity.
    Client client = new Client(<organization_name>, <application_name>);
    client.setApiUrl(<url to hit>);
    client.authorizeAppUser(<username>, <password>);
    client.createEntity(dataParams);
    String <uri> = <collection_name> + "/" + <entity_name>;
    ApiResponse response = client.httpRequest(HttpMethod.POST,ApiResponse.class, null, dataParams, <organization_name>, <application_name>,
            <uri>);
    return response;
    }

编辑1

'References
' 1) Microsoft Internet Controls
' 2) Microsoft HTML Object Library

Sub test()
    Dim oHTML_Element As IHTMLElement
    Dim oBrowser As InternetExplorer
    Dim ie As Variant
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.navigate "" ' Your webpage goes here
        While ie.readyState <> READYSTATE_COMPLETE And ie.readyState <> READYSTATE_LOADED
            DoEvents
        Wend
    For Each oHTML_Element In ie.document.getElementsByName("submit")
        oHTML_Element.Click
    Next
End Sub

答案 1 :(得分:1)

CSS选择器:

您可以使用通过querySelector的{​​{1}}方法应用的CSS选择器。

document

以带有属性button[type=submit] 的{​​{1}}标签和值为button的元素读取。 type将检索第一个匹配项。


CSS查询:

CSS query


VBA:

"submit"