目前只會寫到以下登入網頁,但希望可以透過自動化取代每日人工作業,可以請大師們幫幫忙嗎~~~~
另外想請問大師們如果這不用VBA來寫,是不是用.vbs或.bat也可以做到,或哪一個會比較有效率呢?謝謝∼∼∼∼
------------------------------------------------------------------------
Sub test()
Dim a As Object, b As Object
Set a = CreateObject("internetexplorer.application")
With a
.navigate "http://10.178.1.140:8023/Login.aspx"
Do While .ReadyState <> 4
DoEvents
Loop
.Visible = True
Set b = .Document.all.tags("INPUT")
.Document.all.txtUserName.innertext = "XXXXX"
.Document.all.txtPassword.innertext = "XXXXX"
.Document.all.btnLogin.Click
End With
End Sub
------------------------------------------------------------------------
以上可以登入網頁,登入後的網址會變成http://10.178.1.140:8023/ConditionPage/ConditionEmpty.aspx
不過登入後要點選的步驟+圖文說明可能會有點長,所以我把它放到附檔,如果可以~~~~~希望這些每天人工重複動作的步驟可以自動執行
[attach]28407[/attach]
[attach]28408[/attach]
Sub 自動登入()
Dim a As Object
Set myIE = CreateObject("InternetExplorer.Application")
With myIE
.Visible = False
.Navigate "http://10.178.1.140:8023/Login.aspx" '登入網址
Do While .ReadyState <> 4
DoEvents
Loop
Set a = .document.all.tags("INPUT")
.document.all.txtUserName.innertext = "BS0110" '登入帳號
.document.all.txtPassword.innertext = "BS0110" '登入密碼
.document.all.btnLogin.Click '點選登入按鈕
Do Until .ReadyState = 4
DoEvents
Loop
.Navigate "http://10.178.1.140:8023/ConditionPage/ConditionAgentDay.aspx" '查詢數據網址
Application.Wait Now + 2 / 86400 '等待2秒
.document.all.ctl00_tvReportListt16.Click '點選進入數據網址的確認按鈕
Application.Wait Now + 2 / 86400 '等待2秒
.Navigate "javascript:__doPostBack('ctl00$phCondition3$cldDate','6656')" '點選查詢日期'6656'代表數字23,也就是當月23號
Application.Wait Now + 2 / 86400 '等待2秒
.document.forms(0).all("ctl00_btnConfirm").Click '點選查詢按鈕
Application.Wait Now + 2 / 86400 '等待2秒
.Navigate "http://10.178.1.140:8023/ReportPage/ReportAgentToDay_28_tptv.aspx" '查詢數據會自動產生於此網址頁面
Do Until .ReadyState = 4
DoEvents
Loop
.document.forms(0).all("ctl00_btnDownload").Click '點選下載按鈕