+ Reply to Thread
Results 1 to 3 of 3

How do you fire HTML events using Excel to automate IE?

  1. #1
    Jason
    Guest

    How do you fire HTML events using Excel to automate IE?

    Hi,

    I'm trying to automate a web form-filling process by using Excel to control
    IE, similar to the way discussed in the most helpful "Web Browser Question"
    thread found here:

    http://www.microsoft.com/office/comm...xp=&sloc=en-us

    The website has 2 combo/dropdown boxes called "Name" and the 2nd called
    "Type". In all cases, I would like to set the "Type" to 'Other'.

    The problem is that the value of Type equating to 'Other' changes depending
    on the value of Name. So for example, if Name.value="A" then the 'Other'
    option for Type is set to "X". But if Name.value="B" then to choose 'Other'
    we need Type.value="Y".

    Having looked through the HTML source code, I have identified that this
    assignment is done in a Name_onchange() event, fired when the *selection* of
    Name is changed. Therefore, changing the value of Name in code using

    IE.Document.All.Item("Name").Value="A"

    unfortunately does not cause this event to fire, meaning that the 'Other'
    option for Type will never have been set to "X", hence the line

    IE.Document.All.Item("Type").Value="X"

    will fail to set Type to 'Other'.


    ****
    So my question is: What line(s) of code do I need to have IE recognise that
    the Name value has changed, therefore firing the the Name_onchange() event?
    Would I need something like a Name.Select="A" (don't know the syntax so I
    can't get this working...) to simulate a manual selection, or something else?
    I would really appreciate any ideas and help!! Thanks very much in advance
    everyone!



  2. #2
    Shetty
    Guest

    Re: How do you fire HTML events using Excel to automate IE?

    Use .Navigate Javascript......
    to fire that event if it uses java script.

    Regards,


    Jason wrote:
    > Hi,
    >
    > I'm trying to automate a web form-filling process by using Excel to

    control
    > IE, similar to the way discussed in the most helpful "Web Browser

    Question"
    > thread found here:
    >
    >

    http://www.microsoft.com/office/comm...xp=&sloc=en-us
    >
    > The website has 2 combo/dropdown boxes called "Name" and the 2nd

    called
    > "Type". In all cases, I would like to set the "Type" to 'Other'.
    >
    > The problem is that the value of Type equating to 'Other' changes

    depending
    > on the value of Name. So for example, if Name.value="A" then the

    'Other'
    > option for Type is set to "X". But if Name.value="B" then to choose

    'Other'
    > we need Type.value="Y".
    >
    > Having looked through the HTML source code, I have identified that

    this
    > assignment is done in a Name_onchange() event, fired when the

    *selection* of
    > Name is changed. Therefore, changing the value of Name in code using
    >
    > IE.Document.All.Item("Name").Value="A"
    >
    > unfortunately does not cause this event to fire, meaning that the

    'Other'
    > option for Type will never have been set to "X", hence the line
    >
    > IE.Document.All.Item("Type").Value="X"
    >
    > will fail to set Type to 'Other'.
    >
    >
    > ****
    > So my question is: What line(s) of code do I need to have IE

    recognise that
    > the Name value has changed, therefore firing the the Name_onchange()

    event?
    > Would I need something like a Name.Select="A" (don't know the syntax

    so I
    > can't get this working...) to simulate a manual selection, or

    something else?
    > I would really appreciate any ideas and help!! Thanks very much in

    advance
    > everyone!



  3. #3
    Jason
    Guest

    Re: How do you fire HTML events using Excel to automate IE?

    Hi Shetty,

    Firstly many thanks for your reply, and many thanks for your very detailed
    and helpful replies in "Web Browser Question"!

    Yes, the site uses Javascript, but I'm still a little confused...I'm a
    newbie to automation, so please bear with me...

    So if the list for "Type" is generated in the "Name_onchange()" event when
    the dropdown selection for "Name" is changed, how should I modify my code
    (below) to fire this?

    At the moment I have:

    -------------------------------------
    Sub Test()

    Dim IE as InternetExplorer
    Dim MyCtrl as Object

    Set MyCtrl = IE.Document.All.Item("Name")
    MyCtrl.Value = "A"

    End Sub
    -------------------------------------

    Unforunately, as you probably realise, this doesn't fire the event. Where
    should I insert the ".Navigate Javascript" command, and could you please help
    me specify the correct syntax?

    I really appreciate your help- thankyou!


    "Shetty" wrote:

    > Use .Navigate Javascript......
    > to fire that event if it uses java script.
    >
    > Regards,
    >
    >
    > Jason wrote:
    > > Hi,
    > >
    > > I'm trying to automate a web form-filling process by using Excel to

    > control
    > > IE, similar to the way discussed in the most helpful "Web Browser

    > Question"
    > > thread found here:
    > >
    > >

    > http://www.microsoft.com/office/comm...xp=&sloc=en-us
    > >
    > > The website has 2 combo/dropdown boxes called "Name" and the 2nd

    > called
    > > "Type". In all cases, I would like to set the "Type" to 'Other'.
    > >
    > > The problem is that the value of Type equating to 'Other' changes

    > depending
    > > on the value of Name. So for example, if Name.value="A" then the

    > 'Other'
    > > option for Type is set to "X". But if Name.value="B" then to choose

    > 'Other'
    > > we need Type.value="Y".
    > >
    > > Having looked through the HTML source code, I have identified that

    > this
    > > assignment is done in a Name_onchange() event, fired when the

    > *selection* of
    > > Name is changed. Therefore, changing the value of Name in code using
    > >
    > > IE.Document.All.Item("Name").Value="A"
    > >
    > > unfortunately does not cause this event to fire, meaning that the

    > 'Other'
    > > option for Type will never have been set to "X", hence the line
    > >
    > > IE.Document.All.Item("Type").Value="X"
    > >
    > > will fail to set Type to 'Other'.
    > >
    > >
    > > ****
    > > So my question is: What line(s) of code do I need to have IE

    > recognise that
    > > the Name value has changed, therefore firing the the Name_onchange()

    > event?
    > > Would I need something like a Name.Select="A" (don't know the syntax

    > so I
    > > can't get this working...) to simulate a manual selection, or

    > something else?
    > > I would really appreciate any ideas and help!! Thanks very much in

    > advance
    > > everyone!

    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1