Hi all,
I am having problem clicking a button in an Internet Browser where the source code for the button only gives the (1) input type & (2) id BUT not the (3) name!
SOURCE CODE FOR BUTTON WITHOUT NAME
<input type="button" id="ImportingButton" class="C00_Button1" value="Importingvalue" *******="performUpload();"/>
I have already successfully written a code to click internet buttons WITH names:
SOURCE CODE FOR BUTTON WITH NAME
<input type="button" name="ImportingButton" id="ImportingButton" class="C00_Button1" value="Importingvalue" *******="performUpload();"/>
VBA CODE TO CLICK BUTTON
Sub ClickButton()
Dim objIE as InternetExplorer, appIE as InternetExplorer
Dim btnInput as MSHTML.HTMLInputElement
Dim ElementCol As MSHTML.IHTMLElementCollection
Dim Done as Long, Nm as Long
Dim url as string
Application.ScreenUpdating = False
Nm = 1234
Set appIE = New InternetExplorer
url = (the website link I'm trying to access)
' ---- click the editbutton (start) ----
Set ElementCol = appIE.document.getElementsByTagName("Input")
For Each btInput In ElementCol
If btInput.name = "ImportingButton" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
' --- click the editbutton (end) ---
End Sub
** MODIFIED VBA CODE TO CLICK BUTTON **
Sub ClickButton()
Dim objIE as InternetExplorer, appIE as InternetExplorer
Dim btnInput as MSHTML.HTMLInputElement
Dim ElementCol As MSHTML.IHTMLElementCollection
Dim Done as Long, Nm as Long
Dim url as string
Application.ScreenUpdating = False
Nm = 1234
Set appIE = New InternetExplorer
url = (the website link I'm trying to access)
' ---- click the editbutton (start) ----
Set ElementCol = appIE.document.getElementsByTagName("Input")
For Each btInput In ElementCol
If btInput.ID = "ImportingButton" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
' --- click the editbutton (end) ---
End Sub
When I ran the above macro, the program hung & I had to force-stop the macro by pressing 'Ctrl-Break'
When I investigated the debugging portion --> it highlighted the code 'btnInput.ID...'
Believe this can be solved BUT no clue now..Hope someone can advise!!
Thanks everyone!!!
I am having problem clicking a button in an Internet Browser where the source code for the button only gives the (1) input type & (2) id BUT not the (3) name!
SOURCE CODE FOR BUTTON WITHOUT NAME
<input type="button" id="ImportingButton" class="C00_Button1" value="Importingvalue" *******="performUpload();"/>
I have already successfully written a code to click internet buttons WITH names:
SOURCE CODE FOR BUTTON WITH NAME
<input type="button" name="ImportingButton" id="ImportingButton" class="C00_Button1" value="Importingvalue" *******="performUpload();"/>
VBA CODE TO CLICK BUTTON
Sub ClickButton()
Dim objIE as InternetExplorer, appIE as InternetExplorer
Dim btnInput as MSHTML.HTMLInputElement
Dim ElementCol As MSHTML.IHTMLElementCollection
Dim Done as Long, Nm as Long
Dim url as string
Application.ScreenUpdating = False
Nm = 1234
Set appIE = New InternetExplorer
url = (the website link I'm trying to access)
' ---- click the editbutton (start) ----
Set ElementCol = appIE.document.getElementsByTagName("Input")
For Each btInput In ElementCol
If btInput.name = "ImportingButton" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
' --- click the editbutton (end) ---
End Sub
** MODIFIED VBA CODE TO CLICK BUTTON **
Sub ClickButton()
Dim objIE as InternetExplorer, appIE as InternetExplorer
Dim btnInput as MSHTML.HTMLInputElement
Dim ElementCol As MSHTML.IHTMLElementCollection
Dim Done as Long, Nm as Long
Dim url as string
Application.ScreenUpdating = False
Nm = 1234
Set appIE = New InternetExplorer
url = (the website link I'm trying to access)
' ---- click the editbutton (start) ----
Set ElementCol = appIE.document.getElementsByTagName("Input")
For Each btInput In ElementCol
If btInput.ID = "ImportingButton" Then
Done = Done + 1
btnInput.Click
End If
Next btnInput
' --- click the editbutton (end) ---
End Sub
When I ran the above macro, the program hung & I had to force-stop the macro by pressing 'Ctrl-Break'
When I investigated the debugging portion --> it highlighted the code 'btnInput.ID...'
Believe this can be solved BUT no clue now..Hope someone can advise!!
Thanks everyone!!!