1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Getting Excel to automatically open a webpage and click a button...

Discussion in 'Business Applications' started by bapcki1, Nov 14, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. bapcki1

    bapcki1 Thread Starter

    Joined:
    Nov 12, 2011
    Messages:
    5
    Hi Everyone!

    I have a problem with automated IE button clicking - if anybody could help that would be A-M-A-Z-I-N-G!

    On youtube videos there is a button to 'show video statistics' (its the graph-like button directly to the right of the number of plays)

    I want to take information from these statistics and paste them into excel automatically.

    I have got the VBA code to copy paste it into excel but I can't get the webpage to load up with these stats showing automatically.

    I'm inexperienced when it comes to VBA but I've managed to piece together from forum posts this so far:

    Option Explicit
    Public myIE As Object

    Sub OpenIE()
    Set myIE = CreateObject("InternetExplorer.Application")
    myIE.Navigate "http://www.youtube.com/watch?v=wCBRC14FK_Y"
    myIE.Visible = True
    Application.Wait (Now + TimeSerial(0, 0, 5))
    myIE.document.all("watch-insight-button").Click
    SendKeys "^a"
    SendKeys "^c"
    End Sub

    I've just randomly chosen a chess tutorial video for the purpose of the example - the YouTube video loads but it doesn't get chance to select all and copy because it comes up with 'run-time error 70: permission denied' before it gets to that part.

    When I click Debut, it highlights:

    myIE.document.all("watch-insight-button").Click

    I got the button's ID from this:

    <button onclick=";return false;" title="Show video statistics" type="button" id="watch-insight-button" class="yt-uix-tooltip yt-uix-tooltip-reverse yt-uix-button yt-uix-tooltip yt-uix-button-empty" data-button-action="yt.www.watch.actions.stats" role="button"><img class="yt-uix-button-icon yt-uix-button-icon-watch-insight" src="//s.ytimg.com/yt/img/pixel-vfl3z5WfW.gif" alt=""></button>

    Is it possible to do what I would like?

    Can anybody help me please?

    Thank you !


    Paddy
     
  2. scotty718

    scotty718

    Joined:
    Nov 19, 2010
    Messages:
    185
    You could possibly do a download of the youtube page onto a sheet... using an external data query, then use vba to find the statistics you need and paste them on another sheet? I did something similar a year-or-so back for a client with getting book prices from one of those sites that compares used-book prices.
     
  3. bapcki1

    bapcki1 Thread Starter

    Joined:
    Nov 12, 2011
    Messages:
    5
    Hi Scotty,

    Thanks for your suggestion :)!

    With an external data query, I thought u can only download what is visable/highlightable on the webpage from the URL no? The data I need is only accessible by clicking the 'show video statistics' once on the page..

    Any ideas?

    Paddy

    Am I wrong
     
  4. scotty718

    scotty718

    Joined:
    Nov 19, 2010
    Messages:
    185
    You are probably right, though it may be worth a shot, because you never no what might be downloaded. It only takes a second to pull it manually to see if it gets you what you want...

    Other than that I don't have any ideas except that I heard there was a tool that is like a macro for website actions... like it records the steps you take a website and you can automate it. I forget the name at this point, but it may be worth a google search.

    Sorry I can't be more helpful, but please do post your solution so that I, and others, can benefit from your findings.
     
  5. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    That is strange because when I step through your code in debug mode I don't get an error at all. The page loads fine and the statistics are displayed as intended.

    Rollin
     
  6. scotty718

    scotty718

    Joined:
    Nov 19, 2010
    Messages:
    185
    I just did the same, but I got Run-time error 462: The remote server machine does not exists or is unavailable.

    However, this is most likely due to the fact that my company has a pretty strict internet policy, and I cannot view YouTube at all.

    The reason I bring this up, is that you may not have the rights to view the page, backpi1. Not sure if that's the reason, just a thought.
     
  7. bapcki1

    bapcki1 Thread Starter

    Joined:
    Nov 12, 2011
    Messages:
    5
    That is BIZARRE!? - I just tried the code at work and it worked perfectly!? Thanks for trying it out and telling me! Grazzi!Grazzi!Grazzi!Grazzi!Grazzi!Grazzi!

    Paddy
     
  8. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1026894

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice