Avatar of J P
J P
 asked on

Interact with Webpage from Outlook

I have the following code which successfully opens a hyperlink in internet explorer from an email in Outlook.

My next question is how do I interact with the webpage?

For example I would like to select option 83 from ID "ctl00_cph_MAIN_ddlHCLaction" which is a dropdown.

I have tried
oIE.document.GetElementbyID("ctl00_cph_MAIN_ddlHCLaction").value = 83

Open in new window

but I get the error

'Run-time error '-2147467259 (80004005)': method 'document' of object 'IWebBrowser2' failed.'

Sub macro()

Dim regex
    Set objOL = CreateObject("Outlook.Application")
    Set NewMail = objOL.ActiveExplorer.Selection.Item(1)
    NewMail.Display
    res = NewMail.Body
    
    Set regex = CreateObject("VBScript.RegExp")

    With regex
        .Global = False
        .MultiLine = False
        .IgnoreCase = True
        .Pattern = "HYPERLINK ""([^""]+?)""Click here to access enquiry"
    End With
    Set mtches = regex.Execute(res)
        If mtches.Count > 0 Then
            strHL = mtches(0).submatches(0)
            Set oIE = New InternetExplorerMedium
            oIE.navigate strHL, CLng(2048)
            oIE.Visible = True
        End If
End Sub

Open in new window

OutlookVB ScriptVBAMicrosoft OfficeMicrosoft Development

Avatar of undefined
Last Comment
Qlemo

8/22/2022 - Mon
J P

ASKER
Rgonzo1971 are you available to help?
ASKER CERTIFIED SOLUTION
Qlemo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes