简体   繁体   English

VBA 未按元素 ID 填写

[英]VBA not filling in by element ID

I have got some trubles with my code.我的代码有一些问题。 It works fine on Sharepoint site - its dummy site for me to practice and get things done;它在 Sharepoint 站点上运行良好 - 它是我练习和完成工作的虚拟站点; but on working site its not working.但在工作现场它不工作。 Problem is, I have e-mail, got all elements from it and trying to auto fill in on site, but nothing happens Parsing is going like this:问题是,我有电子邮件,从中获取所有元素并尝试在现场自动填写,但没有任何反应解析是这样的:

Dim ie As InternetExplorerMedium

Set ie = New InternetExplorerMedium

ie.Visible = True
ie.Navigate2 MarrPlazaWebForm

Do
    DoEvents
Loop Until ie.Busy <> True Or ie.readyState = READYSTATE_COMPLETE

With ie
    .document.getElementById("label-for-pass_date_to").value = dateFrom
    .document.getElementById("label-for-pass_date_from").value = dateTo
    .document.getElementById("label-for-pass_username").value = guestName
    .document.getElementById("label-for-pass_description").value = requestorName
    .document.getElementById("pass_full_day").Checked = True

    Set elems = .document.getElementsByClassName("btn btn-primary")
    For Each e In elems
        If (e.getAttribute("type") = "submit") Then
            e.Click
            Exit For
        End If
    Next e
End With

On Error Resume Next
ie.Quit

The site does not get elements by id and just leaves them empty该网站不通过 id 获取元素,只是将它们留空

The site code with elements looks like this:带有元素的站点代码如下所示:

<input type="text" id="label-for-pass_date_to" name="pass_date_from" class="form-control js-datepicker-from hasDatepicker" autocomplete="off" placeholder="From" data-datepicker-disabled-date-before="true" data-mask="date">
<input type="text" id="label-for-pass_date_from" name="pass_date_to" class="form-control js-datepicker-to hasDatepicker" autocomplete="off" placeholder="Untill" data-datepicker-disabled-date-before="true" data-mask="date">
<input type="text" id="label-for-pass_username" name="pass_username[0]" class="form-control" placeholder="Name of guest">

and so on...等等...

I have suspicion, that maybe the working site is composed in JavaScript and all Id's are not what im looking for Any suggestions?我怀疑,也许工作站点是由 JavaScript 组成的,所有的 ID 都不是我要找的任何建议?

I finally found out the problem我终于发现了问题

Dim ie As InternetExplorerMedium - I used "InternetExplorer", and it started to work as it should be. Dim ie As InternetExplorerMedium - 我使用了“InternetExplorer”,它开始正常工作。

Thanks for your suggestions and responses - hope it will come in handy I still don't get it, why it worked out like this - maybe due some security polices in my company感谢您的建议和回复-希望它会派上用场我仍然不明白,为什么会这样-可能是由于我公司的一些安全政策

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM