有没有一种方法可以使用VBA将值传递给网页?

时间:2019-07-16 03:49:51

标签: html excel vba

我正在使用SAP Bex,在登录后,我需要填写文本框来获取数据。如何使用Excel VBA将数据解析到Web?

我能够解析ID和密码。但不适用于下一页上的其他框

    Sub test()

    Set ie = CreateObject("InternetExplorer.Application")
    my_url = "https://jwpwas.maxtree.com/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fcom.sap.pct!2fplatform_add_ons!2fcom.sap.ip.bi!2fiViews!2fcom.sap.ip.bi.bex?QUERY=YZCSMSOSU1_Q0002_MTD_ENA_BC_P&VARIABLE_SCREEN=X&DUMMY=1"

    With ie
        .Visible = True
        .navigate my_url

    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop

    End With

' Input the userid and password
    ie.document.getElementById("j_username").Value = "myID"
    ie.document.getElementById("j_password").Value = "myPassword"
    ie.document.getElementById("uidPasswordLogon").click

   ie.document.getElementById("DLG_VARIABLE_vsc_cvl_VAR_2_INPUT_inp").value = "11"

**---- Below is the html source -----**

    <INPUT onchange="sapUrMapi_InputField_change('DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp',event);" tabIndex=0 onkeyup="sapUrMapi_InputField_KeyUp('DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp',event);" onfocus="sapUrMapi_InputField_focus('DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp',event);" onblur="sapUrMapi_InputField_Blur('DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp',event);" id=DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp class="urEdf2TxtEnbl urEdf2TxtHlp" onselectstart="sapUrMapi_InputField_onselectstart('DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp',event);" onkeydown="sapUrMapi_InputField_keydown('DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp',event);" name=DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp ct="I" f4always="false" ti="0" tp="STRING" st="" autocomplete="off" oldvalue>

Input name is "DLG_VARIABLE_vsc_cvl_VAR_1_INPUT_inp"

enter image description here

0 个答案:

没有答案