Results 1 to 6 of 6

Thread: VBA Internet Explorer Click a button

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    VBA Internet Explorer Click a button

    Name:  Clickbutton.jpg
Views: 185
Size:  11.2 KB


    Hi there, im using vba to access internet explorer, im having problem to click the button "导出“ from the span as shown as above picture, which allows me to export current table out from this website. Please help, thanks.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VBA Internet Explorer Click a button

    what code have you tried? and what results?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: VBA Internet Explorer Click a button

    Hi I have tried the following:

    option 1____________________________________________

    Set oElementCollection = objIE.document.getElementById("btnExport")


    For Each link In oElementCollection
    If link.innerHTML = "导出" Then
    link.Click
    Exit For
    End If
    Next link

    option 2 ____________________________________________

    objIE.document.getElementById("btnExport").Click

    ____________________________________________

    All of the above options do not work.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VBA Internet Explorer Click a button

    if you want to pm me with a link to the actual site, include username and password, i will have a look and test
    other than that, if the button is on a form, have you tried tried to submit the form?

    many sites try to make it as difficult as possible to automate their pages, even if the button can be clicked, it may need some other javascript or other to authenticate that the button was actually clicked by mouse
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2021
    Posts
    3

    Re: VBA Internet Explorer Click a button

    Sorry I cant provide the username and password, this is company internal website. the button is on top of a table. Im not sure if it is a form or not. Any other suggestion I can try?

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VBA Internet Explorer Click a button

    this is company internal website
    as it is internal, ask whoever designed it to provide an API, not much anyone external can do anything to help, can't see the html code of the page or test against the site
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width