how to display a web page in outlook 2007 using code

COHFL
COHFL used Ask the Experts™
on
HI there,
I have a form in outlook 2007 and i'm trying to create aform that when someone opens it a webpage is display it.
the code has something like this:
Function Item_Open()
WebBrowser1.navigate "www.experts-exchange.com"
End Function

but this throws an error saying WebBrowser1 does not exist
what do i need to do in order to fix my form
Thanks,
COHFL
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
Hello COHFL,

You need to declare the object ... see below.  The visible can be moved in front of the loop if you want to see what is happening straight away

Regards,

chris_bottomley
Sub ieTest() 
Dim objIE As Object 
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Navigate2 "www.experts-exchange.com"
 
    'Wait until load is completed
    Do While objIE.readystate <> 4
        DoEvents
    Loop
    objIE.Visible = True 
End Sub

Open in new window

Author

Commented:
how do i call it from my Item_Open

just ietest()
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
Either embed the code inyour item_open or yes call ietest

Chris
Function Item_Open()
Dim objIE As Object 
 
    Set WebBrowser1 = CreateObject("InternetExplorer.Application")
    WebBrowser1.navigate2 "www.experts-exchange.com"
    'Wait until load is completed
    Do While WebBrowser1.readystate <> 4
        DoEvents
    Loop
    WebBrowser1.Visible = True 
 
End Function

Open in new window

Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
ok but this code actually opens a new IE page. I need to open the webbrowser i have added to the form. how can i do this?
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
Can you supply your file?

Chris

Author

Commented:
how can i get the file out?
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
Jolly good question, I suspect from my wording I momentarily forgot it was outlook.

Can you export the form and any code modules then zip them up, (I thik the file will need renaming as something other thasn zip)  Then add as an attachment.  Otherwise a paste of the form code in the first instance may be helpful.

Chris
Commented:
ok here i got the answer:

Sub Item_Open()
    Set oInspector = Item.GetInspector
    Set oPage = oInspector.ModifiedFormPages("Message")    
    Set oControl = oPage.Controls("WebBrowser1")
    oControl.Navigate2 "http://google.com"
End Sub
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
LOoks like tha's it resolved then ... or am I missing something here?

Chris

Author

Commented:
nope it is resolved
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial