Clicking an image

OHtoMSP

New Member
Joined
Aug 26, 2011
Messages
7
I'm trying to click an image in Internet Explorer using VBA, but I can't figure out how to reference it since it has no name.

HTML:
<IMG tabindex="10" *******="ContinueButton()"
         onkeypress="ContinueButton()" src="images/btn_continue.gif"
         alt="Next Create Page"></TD>

Thanks for the help!
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hello OHtoMSP,

Here is an example macro. You can locate the image by its alt property by looping through the images collection. Change the URL to what you are using. If you need help adapting the macro to your code, let me know.
Rich (BB code):
Sub ClickImageExample()

  Dim ieApp As Object
  Dim ieImages As Object
  Dim ieImage As Object
  Dim URL As String
  
  ' Change the URL below to what you will be using
    URL = "www.google.com"
    
    Set ieApp = CreateObject("InternetExplorer.Application")
    
      ieApp.Navigate URL
      ieApp.Visible = True
      
      While ieApp.Busy Or ieApp.ReadyState <> 4: DoEvents: Wend
      
      Set ieImages = ieApp.Document.Images
      
      For Each ieImage In ieImages
        If ieImage.Alt = "Next Create Page" Then
           ieImage.Click
           Exit For
        End If
      Next ieImage
      
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,866
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top