Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8697857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:37:02+00:00 2026-06-13T01:37:02+00:00

In VBA is it possible to intercept a javascript onchange event and grab the

  • 0

In VBA is it possible to intercept a javascript onchange event and grab the originating ID# in the webbrowser control?

<select name="status0" id="status0" onchange="javascriptonchangeeventhere">

The above code is a combobox demo, If I were to select an item from the combobox, it would process onchange in javascript. What it does is pull up a form containing current date and reference number, instead I would like to pull up my own userform and then spit that data into a related (notes0) field. How would I intercept this when it occurs so I can assign it to the correct field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:37:02+00:00Added an answer on June 13, 2026 at 1:37 am

    Here’s a short example. Project references set for “Microsoft HTML object library” and “Microsoft internet controls”

    In a class module “clsEvents”:

    Option Explicit
    
    Public WithEvents slct As MSHTML.HTMLSelectElement
    Public WithEvents href As MSHTML.HTMLAnchorElement
    
    'Note that having defined "href" as "WithEvents", if you choose "href"
    '  from the left-hand dropdown at the top of the class code module
    '  then the right-hand dropdown will populate with events you can select
    '  from to create an event-handling procedure in the class
    
    Private Function href_onclick() As Boolean
        Debug.Print "link clicked"
        href_onclick = False 'cancels the navigation
    End Function
    
    Private Sub slct_onchange()
        Debug.Print "select onchange - value is " & slct.Value
    End Sub
    
    Private Function slct_onclick() As Boolean
        Debug.Print "select onclick - value is " & slct.Value
    End Function
    

    In a regular module:

    Option Explicit
    
    Dim evt As clsEvents
    
    Sub Setup()
    
        Dim IE As New InternetExplorer
        Dim el As Object, el2 As Object
    
        Set evt = New clsEvents
    
        IE.Visible = True
        IE.navigate "http://www.csee.wvu.edu/~riggs/html/select_example.html"
    
        Do While IE.Busy
        Loop
    
        Set el = IE.document.getElementsByTagName("select")(1)
        Set el2 = IE.document.getElementsByTagName("a")(1)
    
        If Not el Is Nothing Then
            Debug.Print "setting event capture: currentvalue=" & el.Value
            Set evt.slct = el
        End If
    
        If Not el2 Is Nothing Then
            Debug.Print "setting event capture on link:" & el2.innerText
            Set evt.href = el2
        End If
    
    End Sub
    

    If you run the Setup sub and then change the value of the second select or click the “Javascript” link on the page in IE you should see output in the Immediate window of the VB editor.

    Hope that helps get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to control the Tools->Options->View->View Whitespace between pages through VBA/Macros? Thanks.
Is it possible in Microsoft Outlook VBA to catch the Open event of any
Possible Duplicate: Version control for VBA file Does any kind of version control exist?
Possible Duplicate: How to search for string in MS Access VBA array I am
Is it possible to format time in [h]:mm format using VBA? [h]:mm format in
Possible Duplicate: Can not connect to Oracle via VBA - Driver's SQLSetConnectAttr Failed I
In VBA programming, is it possible to hide the ToolTipText for a Slider Bar?
I am using Excel VBA 2003. Is it possible to create new recordset by
VBA is throwing the above given error on the line Sheets(Sheet1).Range(A & i).Copy Destination:=Sheets(Sheet2).Range(A
Is it possible to create VBA function programmatically from a VSTO add-in?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.