IEフォームに値をセットしてSUBMIT

Excel C列の値をIE上のフィールドにセットしてSUBMIT

Sub batch_all_check()

	Dim IE As Object
	Dim LenX As Integer, PP As String
	Dim Y As Integer, HTML As String
	
	Set IE = CreateObject(“internetExplorer.application")
	IE.Navigate “https://www.xxx"
	IE.Visible = True
	
	Do While IE.Busy = True: DoEvents: Loop
	Do While IE.Busy = True: DoEvents: Loop
	Do While IE.Busy = True: DoEvents: Loop
	
	For Y = 3 To 4002
		
		PP = Cells(Y, 3)
		If PP = “" Then Exit For
		
		PP = UCase(Replace(PP, “-", “"))
		LenX = Len(PP)
		
		If LenX <> 20 Then
			Cells(Y, 5) = “length error"
			Exit For
		End If
	
		Do While IE.Busy = True: DoEvents: Loop
		'文字列を分解してそれぞれのフィールドにセット
		IE.Document.Form1.igtxtwtxedPidPart01.Focus
		IE.Document.Form1.igtxtwtxedPidPart01.Value = Left(PP, 2)
		IE.Document.Form1.igtxtwtxedPidPart02.Focus
		IE.Document.Form1.igtxtwtxedPidPart02.Value = Mid(PP, 3, 6)
		IE.Document.Form1.igtxtwtxedPidPart03.Focus
		IE.Document.Form1.igtxtwtxedPidPart03.Value = Mid(PP, 9, 5)
		IE.Document.Form1.igtxtwtxedPidPart04.Focus
		IE.Document.Form1.igtxtwtxedPidPart04.Value = Mid(PP, 14, 3)
		IE.Document.Form1.igtxtwtxedPidPart05.Focus
		IE.Document.Form1.igtxtwtxedPidPart05.Value = Mid(PP, 17, 4)
		IE.Document.Form1.igtxtwtxedPidPart01.Focus
		'theform.submit()
		IE.Document.Form1.identify_btnVerify.Click
		'ボタン(SUBMIT)をクリック
		Do While IE.Busy = True: DoEvents: Loop
		Do While IE.Busy = True: DoEvents: Loop
		Do While IE.Busy = True: DoEvents: Loop
		'html取り込み
		HTML = IE.Document.Body.innerHTml
	
		If InStr(1, HTML, “***") > 0 Then
			Cells(Y, 5) = “Hit"
		Else
			Cells(Y, 5) = “???"
		End If
	Next
	
	MsgBox “Done!"
	Set IE = Nothing

End Sub

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です