Private Sub UserForm_Activate()
Dim myIE As InternetExplorer
Dim url$, sDoc As Object
Dim x As integer
Set myIE = WebBrowser1
With myIE
url = "公司內網"
.Navigate url
Do While .Busy Or .ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
With .Document
Set x = Row(1, 0)
For Each sDoc In .all.tags("input")
If sDoc.Name = "item" Then sDoc.Value = Range("A1").Offset(x, 0)
If sDoc.Name = "mailNumber" Then sDoc.Value = Range("B1").Offset(x - 1, 0)
x = x + 1
Next
For Each sDoc In .all.tags("input")
If InStr(sDoc.Value, "登入") > 0 Then
sDoc.Click
End If
Next
End With
End With
End Sub
For Each sDoc In .all.tags("input")
'If sDoc.Name = "item" Then sDoc.Value = Range("A1").Offset(x, 0)
'If sDoc.Name = "mailNumber" Then sDoc.Value = Range("B1").Offset(x - 1, 0)
x = x + 1
debug.print sDoc.Name
Next作者: ts00690106 時間: 2015-8-20 15:27
diolin大你好
考慮到所有的input 我將所有input值都填上了
Private Sub UserForm_Activate()
Dim myIE As InternetExplorer
Dim url$, sDoc As Object
Dim x As Integer
Set myIE = WebBrowser1
With myIE
url = "公司內網"
.Navigate url
Do While .Busy Or .ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
With .Document
For Each sDoc In .all.tags("input")
If sDoc.Name = "Sys_BatchNumber" Then sDoc.Value = [M1]
If sDoc.Name = "Sys_mailNumber1" Then sDoc.Value = [N1]
If sDoc.Name = "Sys_mailNumber2" Then sDoc.Value = [O1]
If sDoc.Name = "ChkPasse" Then sDoc.Value = 1
If sDoc.Name = "item" Then sDoc.Value = Range("A1").Offset(x, 0)
If sDoc.Name = "mailNumber" Then sDoc.Value = Range("B1").Offset(x - 1, 0)
If sDoc.Name = "CarNo" Then sDoc.Value = 1
x = x + 1
Next
For Each sDoc In .all.tags("input")
If InStr(sDoc.Value, "登入") > 0 Then
sDoc.Click
End If
Next
End With
End With
End Sub