Opening a webpage with a command button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jwolfley
    New Member
    • Feb 2007
    • 11

    Opening a webpage with a command button

    Can I create a command button that opens IE and pass an associated website address to target? In other words, I list a text link in a form. If I add a button what is the event procedure I need to create to pass along the actual url to IE?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by jwolfley
    Can I create a command button that opens IE and pass an associated website address to target? In other words, I list a text link in a form. If I add a button what is the event procedure I need to create to pass along the actual url to IE?
    The 'No Frills' and 'Simplest' approach by far is:
    __1 Assuming a Text Box on your Form named txtURL.
    __2 Typing a Internet Address into this Text Box. e.g. yahoo.com, microsoft.com, etc.and placing this code in the Click() Event of a Command Button will navigate to that location assuming it is a valid Address.
    __3 You must know the Absolute Path to Internet Explorer for this to work.
    __4 An invalid address will simply produce the This Page cannot be displayed screen within IE.
    __5 You may also want to look into the possibility of incorporating a Microsoft Web Browser Control into your application.
    Code:
    If Len(Me![txtURL]) > 0 Then
      Dim retVal
      retVal = Shell("C:\Program Files\Internet Explorer\Iexplore.exe " & Me![txtURL], vbMaximizedFocus)
    Else
      Exit Sub
    End If

    Comment

    • jwolfley
      New Member
      • Feb 2007
      • 11

      #3
      That worked perfectly! No frills was easy and easy is for me!

      Comment

      • jwolfley
        New Member
        • Feb 2007
        • 11

        #4
        Thank you!

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by jwolfley
          Thank you!
          You're quite welcome.

          Comment

          Working...