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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,562
Messages
6,131,422
Members
449,651
Latest member
Jacobs22

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