M
Madiya
I am using excel vba to access our intranet site.
I am entering login id and password thru vba.
Now I need to click a button on the same page but no matter what I do,
I failed and need your help.
I need to click (programetically by vba) on the view button which in
turn launch a java function of the html source.
here is the vba code I assambled.
Sub IE_NCC_ICC()
Dim MYURL As String
'Dim IE As SHDocVw.InternetExplorer
Dim ie As InternetExplorer
Dim ipf As Object
' Open Internet Explorer application
Set ie = CreateObject("InternetExplorer.Application")
With ie
..Visible = True
..Navigate ("http://10.10.10.10:8000/vms/jsp/ChangeBatchStatus.jsp")
' Loop until the page is fully loaded
Do Until .ReadyState = 4
DoEvents
Loop
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
If InStr(1, ie.StatusText, "Done") _
'*** HTML SOURCE CODE
'RADIO BUTTON ALL VOUCHERS name="radRange" checked
onClick="displayVouchers();
' name="radRange" value="Selected"
onClick="displayVouchers();
'FROM name="txtFrom"
'TO name="txtTo"
'VIEW <INPUT TYPE="button" name="Submit" value=" View "
onClick="nextPage();">
'UPDATE <INPUT TYPE="button" name="Submit" value=" Update "
onClick="changeActive();">
Dim els As Object, e As Object, opt As Object
Set els = ie.Document.getElementsByName("radRange")
For Each e In els
If e.Type = "radio" And e.Value = "Selected" Then
e.Checked = True
Debug.Print "Checked option: '" & e.Value & "'"
Exit For
End If
Next e
Set ipf = ie.Document.all.Item("cboBatchNumber")
ipf.Value = "52585"
Set ipf = ie.Document.all.Item("cboStatus")
ipf.Value = 1 '"ACTIVE"
Set ipf = ie.Document.all.Item("txtFrom")
ipf.Value = "300"
Set ipf = ie.Document.all.Item("txtTo")
ipf.Value = "49"
' *** THIS IS THE PROBLEM AREA
'.Item("radRange").Value("Selected") = Checked
'ie.Document.Item("radRange").Value("Selected") = Checked
'Set ie.Document.Item("radRange").Value = "Selected"
'Set ipf = ie.Document.all.Item("radRange")
'
'ipf.Click
'.JAVASCRIPT "displayVouchers()"
'ipf.Value = "Selected"
'ipf.Select ' = True
'MsgBox ipf.Type
'ipf.Checked = True
Set ipf = ie.Document.all.Item(" View ")
ipf.Value = " View "
ipf.Click
Button.Click
..Navigate ("http://10.10.10.10:8000/vms/jsp/
NextUpdateVoucherStatus.jsp")
Set ipf = ie.Document.all.Item("Submit")
ipf.Value = " View "
ipf.Click
ipf.SUBMIT
'Set IPF = IE.Document.all.Item("cboBatchNumber")
'IPF.Value = "50545"
'Set IPF = IE.Document.all.Item("cboBatchNumber")
'IPF.Value = "50545"
'http://10.10.10.10:8000/vms/jsp/NextUpdateVoucherStatus.jsp
'http://10.10.10.10:8000/vms/jsp/ChangeToActive.jsp
End With
End Sub
I am entering login id and password thru vba.
Now I need to click a button on the same page but no matter what I do,
I failed and need your help.
I need to click (programetically by vba) on the view button which in
turn launch a java function of the html source.
here is the vba code I assambled.
Sub IE_NCC_ICC()
Dim MYURL As String
'Dim IE As SHDocVw.InternetExplorer
Dim ie As InternetExplorer
Dim ipf As Object
' Open Internet Explorer application
Set ie = CreateObject("InternetExplorer.Application")
With ie
..Visible = True
..Navigate ("http://10.10.10.10:8000/vms/jsp/ChangeBatchStatus.jsp")
' Loop until the page is fully loaded
Do Until .ReadyState = 4
DoEvents
Loop
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
If InStr(1, ie.StatusText, "Done") _
Loop0 Then Exit Do
'*** HTML SOURCE CODE
'RADIO BUTTON ALL VOUCHERS name="radRange" checked
onClick="displayVouchers();
' name="radRange" value="Selected"
onClick="displayVouchers();
'FROM name="txtFrom"
'TO name="txtTo"
'VIEW <INPUT TYPE="button" name="Submit" value=" View "
onClick="nextPage();">
'UPDATE <INPUT TYPE="button" name="Submit" value=" Update "
onClick="changeActive();">
Dim els As Object, e As Object, opt As Object
Set els = ie.Document.getElementsByName("radRange")
For Each e In els
If e.Type = "radio" And e.Value = "Selected" Then
e.Checked = True
Debug.Print "Checked option: '" & e.Value & "'"
Exit For
End If
Next e
Set ipf = ie.Document.all.Item("cboBatchNumber")
ipf.Value = "52585"
Set ipf = ie.Document.all.Item("cboStatus")
ipf.Value = 1 '"ACTIVE"
Set ipf = ie.Document.all.Item("txtFrom")
ipf.Value = "300"
Set ipf = ie.Document.all.Item("txtTo")
ipf.Value = "49"
' *** THIS IS THE PROBLEM AREA
'.Item("radRange").Value("Selected") = Checked
'ie.Document.Item("radRange").Value("Selected") = Checked
'Set ie.Document.Item("radRange").Value = "Selected"
'Set ipf = ie.Document.all.Item("radRange")
'
'ipf.Click
'.JAVASCRIPT "displayVouchers()"
'ipf.Value = "Selected"
'ipf.Select ' = True
'MsgBox ipf.Type
'ipf.Checked = True
Set ipf = ie.Document.all.Item(" View ")
ipf.Value = " View "
ipf.Click
Button.Click
..Navigate ("http://10.10.10.10:8000/vms/jsp/
NextUpdateVoucherStatus.jsp")
Set ipf = ie.Document.all.Item("Submit")
ipf.Value = " View "
ipf.Click
ipf.SUBMIT
'Set IPF = IE.Document.all.Item("cboBatchNumber")
'IPF.Value = "50545"
'Set IPF = IE.Document.all.Item("cboBatchNumber")
'IPF.Value = "50545"
'http://10.10.10.10:8000/vms/jsp/NextUpdateVoucherStatus.jsp
'http://10.10.10.10:8000/vms/jsp/ChangeToActive.jsp
End With
End Sub