Run Macro when Website button selected

WinterTT

New Member
Joined
Nov 8, 2012
Messages
20
Lets assume you have the code below(pulls website up, enters username and password, and submits)
Code:
Function FillInternetForm()
Dim IE As Object
  Set IE = CreateObject("InternetExplorer.Application")
'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title bar.
  IE.Navigate "[URL]https://login.yahoo.com/config/login?.intl=us&.lang=en-US&.partner=&.last=&.src=fpctx&.pd=fpctx_ver%3D0%26c%3D%26ivt%3D%26sg%3D&pkg=&stepid=&.done=http%3a//www.yahoo.com/[/URL]"
'go to web page listed inside quotes
  IE.Visible = True
  While IE.busy
    DoEvents  'wait until IE is done loading page.
  Wend
  IE.document.All("username").Value = "Myusername"
  IE.document.All("passwd").Value = "12345"
  IE.document.All(".save").Click '<`the click in question
End Function

After the click is made how can we automatically run a macro? I've tried
Code:
  If IE.document.All(".save").Click = True Then.....
But that doesn't seem to work.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Why don't you just call the macro after the code to click the button?
 
Upvote 0
...WOW...how did I not even think about that :confused: lol. Brain fart moment, thanks guys.

Just curious though if the user had to manually press submit for one reason or another(wrong password in code for instance, so it manually is entered) how would you get the macro to run?
 
Upvote 0

Forum statistics

Threads
1,216,111
Messages
6,128,899
Members
449,477
Latest member
panjongshing

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