Another Button (link to website)

  • Thread starter Thread starter Neil Greenough
  • Start date Start date
N

Neil Greenough

I have a button on a form and would like to add some VBA to the button.

When the user clicks on the button, I would like their internet package
(either Internet Explorer or Netscape) to open and for them to be taken
straight to http://www.paypal.com

Also, when they click on the button, I would like a confirmation box to
appear, saying "Are you sure you want to access the internet?"

Thanks
 
Could you please elaborate a bit more on this? I am new to VBA and as such,
if possible, could you please tell me the whole code?

Thanks
 
Put this line of code in the On Click Event of the command button you want to
use to get to Paypal.

The Shell function starts an application, in this case Internet Explorer.
It should contain the full path to the application.
C:\Program Files\Internet Explorer\iexplore
The next bit is a command line argument that tells the application
information it can use when it starts. In this case, it is the URL to go to.

http://www.paypal.com
Then, we tell it the Window Style to use. In this case, 3 = Maximized with
Focus.

VBA Help will give you more info if you need it.

One thing to keep in mind. The shell function does not wait for the
application it is calling to complete. The code continues processing.
Usually, this is not a problem, but if it is, let me know and we can deal
with it. I don't want to overload you with info now.

It would look something like this:

Private Sub cmdPayPal_Click()
On Error GoTo cmdPayPal_Err

shell("C:\Program Files\Internet Explorer\iexplore http://www.paypal.com",3)


cmdPayPal_Exit:
Exit Sub

cmdPayPal_Err:
MsgBox Error$
Resume cmdPayPal_Exit

End Sub
 
Back
Top