Есть сайт, на котором есть некоторые данные, которые я хочу получить для своей работы.Я проверяю некоторые флажки и отправляю их, затем веб-сайт отправит мне электронное письмо с моими данными.Но получение моей информации занимает слишком много времени, поэтому я хочу автоматизировать ее, чтобы каждый день в первый час утра запрашивалась информация, например, когда она мне понадобится, я уже получу ее в своем электронном письме.
Iизменил некоторый код, и мне уже удалось войти в систему и перейти на страницу, где мне нужно установить флажок (их три), а затем нажать кнопку отправки.
Sub GetTable()
Dim ieApp As InternetExplorer
Dim ieDoc As Object
Dim ieTable As Object
Dim chkBox As Object
'create a new instance of ie
Set ieApp = New InternetExplorer
'you don’t need this, but it’s good for debugging
ieApp.Visible = True
'assume we’re not logged in and just go directly to the login page
ieApp.Navigate "http://mydata/aspx/mydataLogon.aspx?Language=2"
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
Set ieDoc = ieApp.Document
'fill in the login form – View Source from your browser to get the control names
With ieDoc.forms(0)
.txtUsername.Value = "usertest"
.txtPassword.Value = "test123"
.Submit
End With
Do While ieApp.Busy: DoEvents: Loop
Do Until ieApp.ReadyState = READYSTATE_COMPLETE: DoEvents: Loop
'now that we’re in, go to the page we want
ieApp.Navigate "http://mydata/InventoryTracking/aspx/rptDefault.aspx?rpt=../aspx/invRptDetailReport.aspx"
Set ieDoc = ieApp.Document
With ieDoc
'I tried with getElementbyId, I dont get any error but the chkbox still comes as with a nothing value
Set chkBox = ieDoc.getElementByid("cblPlants_0")
'therefore these give error too, I dont know why. A an object variable or with block variable not set error
chkBox.Click
chkBox.Checked = True
'here I get an object variable or with block variable not set error
ieDoc.getElementByid("cblPlants_0").Click
.Submit
End With
End sub
Элемент управления флажка, который я хочунаходится внутри этого:
'first there is a form and this is how the iframe is first called I think
<form name="_ctl1" method="post" action="rptDefault.aspx" id="_ctl1">
<table width="100%" HEIGHT="100%" cellpadding="0" cellspacing="0" border="0">
<TR>
<TD CLASS="Normal" COLSPAN="4"><IFRAME ID="IFRAME1" NAME="IFRAME1" SRC="../aspx/invRptDetailReport.aspx" frameborder="0" width="100%" height="100%"></IFRAME></TD>
</TR>
'Now the iframe1 goes like this
<form name="frmRptDetailReport" method="POST" action="invRptDetailReport.aspx" id="frmRptDetailReport">
<table id="htblMainBody" width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#E5DBE2">
<tr><td <a id="lbtnSelect" href="javascript:__doPostBack('lbtnSelect','')"</a>
<div id="divChkboxlist" class="scrollingControlContainer scrollingCheckBoxList" onscroll="saveScrollPos();">
<table id="cblPlants" border="0" style="font-family:Arial;font-size:11px;width:275px;overflow: scroll"><tr>
<tr><td><input id="cblPlants_0" type="checkbox" name="cblPlants:0" onclick="javascript:setTimeout('__doPostBack(\'cblPlants$0\',\'\')', 0)" language="javascript" /><label for="cblPlants_0">1X1 -Confecciones</label></td>
</tr>
Как я могу установить этот флажок на этой странице?После того, как флажок будет установлен, я получу электронное письмо, которое мне нужно.
Если вам нужна дополнительная информация, пожалуйста, сообщите мне