More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

share code 22-Nov-2017 16:45

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

Code level: intermediate    Code area: Outlook Form Design Printer Friendly Version
Title: Add a hyperlink button to an Outlook form
Description: A label control on an Outlook form supports a Click event. You can put the text for the hyperlink in the control's caption and use code (adapted for your custom page and control name, of course) to launch the link in the browser when the user clicks the label. One variation is to use a "friendly" name for the Caption property and the real URL for Tag property.
Date: 30-Oct-2002  06:16
Code level: intermediate
Code area: Outlook Form Design
Posted by: Sue Mosher
This message is displayed as VB.NET
 Sub Label1_Click()
    Set objWeb = CreateObject("InternetExplorer.Application")
    objWeb.Navigate Item.GetInspector.ModifiedFormPages _
      ("P.2").Controls("Label1").Caption
    ' alternative
    'objWeb.Navigate Item.GetInspector.ModifiedFormPages _
      ("P.2").Controls("Label1").Tag
    objWeb.Visible = True
End Sub
All 73comments
Page [ 1 2 3 4 5 6 7 8 Next >>  
  30-Oct-2002  06:16   



Where do you insert the code?

I'm in the design form, and don't see where this code can be inserted.



  30-Oct-2002  06:16   
There's a View Code button on the design mode toolbar. Or choose Form | View Code from the menu. You'll see the code window appear.
Sue Mosher


  30-Dec-2002  16:50   
Where do I place my URL in this code? I have this:

Sub Label1_Click()

    Set objWeb = CreateObject("InternetExplorer.Application")

    objWeb.Navigate Item.GetInspector.ModifiedFormPages _

    ("P.2").Controls("http://midrangeweb/newrequest.html").Caption

    objWeb.Visible = True

End Sub
  21-Feb-2003  16:02   
This sub references the control on the specified form page named 'Label1'. Simply edit the properties and set the 'Caption' property to the URL. When you run the form, click on the 'Label1' control and the event is fired to load the browser and navigate to the URL.

 
  04-Mar-2003  21:45   
Just to add to Steve's comment, you don't put the URL in the code at all. Instead, you set the URL as either the Caption or Tag property of the control, the use the original code that I posted. If you change the name of the control from Label1 to something else, change the control name in the code to match.
  10-Mar-2003  11:45   
I tried to run this script but i get an error saying Variable in undefined "webObj" ? any idea ?
  11-Mar-2003  19:40   
If you have an Object Explicit statement at the beginning of your script, you must declare each variable with a Dim statement before making further use of it.
  14-Apr-2003  10:14   
Tried this and I get



script error -"expected statement Line 7" Code as below. Command button was named cmdLink1.



Sub cmdLink1_Click()

    Set objWeb = CreateObject("InternetExplorer.Application")

    objWeb.Navigate Item.GetInspector.ModifiedFormPages _

      ("P.1").Controls("cmdLink1").Caption

    ' alternative

    'objWeb.Navigate Item.GetInspector.ModifiedFormPages _

      ("P.1").Controls("cmdLink1").Tag

    objWeb.Visible = True

End Sub



If the commmand button is on Message or P.1, should I put "Message" where I have put P.1????
  07-May-2003  12:08   
Try this, I know this works, I have it on my form.



Sub Label1_Click()

Set objWeb = CreateObject("InternetExplorer.Application")

objWeb.Navigate Item.GetInspector.ModifiedFormPages _

("xxx").Controls("Label1").Caption

objWeb.Visible = True

End Sub





***Where xxx is the name of the page you have your label or command button in. For Example, if you have the label/command buttn on page 1, then xxx will be P.1, if you have it on page 2, your xxx should be equal to P.2 and so on. Hope this helps.
  30-Jun-2003  07:40   
Michael, yes, the name of the page in your code must match the actual name of the page on the form.
Page [ 1 2 3 4 5 6 7 8 Next >>