+ Reply to Thread
Results 1 to 11 of 11

VBA data grab not working

  1. #1
    Registered User
    Join Date
    07-29-2018
    Location
    In the Queen's Shed
    MS-Off Ver
    2013
    Posts
    23

    Question VBA data grab not working

    I am trying to extract the text from a translated patent using below code. The code should cycle through the divs of the web page and extract the translated text blocks whenever it encounters them.

    What did I do wrong?

    Please Login or Register  to view this content.
    Last edited by Pak Mariman; 03-21-2021 at 09:53 AM.

  2. #2
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: VBA data grab not working

    Well it depends on what the error message is. Did you get one or what was the result? If not, you have to make sure that all the properties are correct. Furthermore, divs almost along with almost everything else in the Dom have a property called length. You have to loop through that. You really should look up the property called get elements by tag name that you are using. are you sure that that returns a collection because that's what you're trying to look at with your code?it's impossible to give you an answer unless you tell what's wrong. You didn't say anything you just said something's wrong.

  3. #3
    Registered User
    Join Date
    07-29-2018
    Location
    In the Queen's Shed
    MS-Off Ver
    2013
    Posts
    23

    Re: VBA data grab not working

    Quote Originally Posted by omahaNative_1023 View Post
    Well it depends on what the error message is. Did you get one or what was the result? If not, you have to make sure that all the properties are correct. Furthermore, divs almost along with almost everything else in the Dom have a property called length. You have to loop through that. You really should look up the property called get elements by tag name that you are using. are you sure that that returns a collection because that's what you're trying to look at with your code?it's impossible to give you an answer unless you tell what's wrong. You didn't say anything you just said something's wrong.
    The code runs, gives no error message, but returns 0 to cell A1.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    According to the url explain at least what is the expected result as after all this is very not a mind readers forum …

  5. #5
    Registered User
    Join Date
    07-29-2018
    Location
    In the Queen's Shed
    MS-Off Ver
    2013
    Posts
    23

    Re: VBA data grab not working

    Quote Originally Posted by Marc L View Post

    According to the url explain at least what is the expected result as after all this is very not a mind readers forum …
    The Original description is here.

    I would want my code to grab the translation here.

  6. #6
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: VBA data grab not working

    Well first of all, the variable you are using to accept or try and accept all of the information coming from all of the div tags and the collection of them, does not make sense doesn't? Because you are getting response text by using XML library from Microsoft but you're not doing anything with that. But to point again, I think the reason you get zero is because obviously nothing is being thrown into variable. That is very common when it comes from a page architected by the Dom. 0 literally means empty set I think when coming from web applications and elements like that in html. It might mean or might indicate a length but not sure about that one. Don't think so. But anyway, I think real issue here is that you are getting zero because, even though you are using valid property and getting collection returned by specifying tag name, a div has many things inside of it, including inner text and inner HTML. If you just ask for a div tag, I don't think you are supposed to get anything. First off, look at those two attributes and try and run code and get information from those. If you can then I may be correct in terms of that's what you need to get info from instead of just top level tag of div.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: VBA data grab not working


    Quote Originally Posted by Pak Mariman View Post
    I would want my code to grab the translation here.
    Which webpage elements, from where until … ?

  8. #8
    Registered User
    Join Date
    07-29-2018
    Location
    In the Queen's Shed
    MS-Off Ver
    2013
    Posts
    23

    Re: VBA data grab not working

    Quote Originally Posted by Marc L View Post

    Which webpage elements, from where until … ?
    I would want to grab all text from

    <div id="DESCRIPTIONmySpanp1s1Text" class="text">Method of grinding the powder using a medium with zirconium orthosilicate </div>

    until and including

    <div id="DESCRIPTIONmySpanp96s0Text" class="text">Particle sizes were determined using a Microtrac® particle size analyzer as described above. </div>

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Quote Originally Posted by Pak Mariman View Post
    What did I do wrong?
    So much to say !

    You did not choose the obvious elements to search for according to any webbrowser inspector tool …

    But far above all, you did not see the initial webpage code you get via the property 'responseText'
    does very not contain any element you wanna grab !
    As once the initial webpage is loaded some java scripts are executed in order to fill the webpage
    like you can check in the initial webpage code or via the inpector tool, whatever …

    So if you really want to import the text under VBA you can do it via piloting Internet Explorer.

  10. #10
    Registered User
    Join Date
    07-29-2018
    Location
    In the Queen's Shed
    MS-Off Ver
    2013
    Posts
    23

    Re: VBA data grab not working

    Quote Originally Posted by Marc L View Post

    So if you really want to import the text under VBA you can do it via piloting Internet Explorer.
    ... how? Is there some example code or relevant literature on how to do this?

  11. #11
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA data grab not working


    Yes, some examples on forums.
    Another way than piloting IE may be via Power Query / Get and Transform depending on the Excel version …

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Grab lines of data from sheet based on multiple criteria (working slightly)
    By kai. in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-30-2018, 04:43 AM
  2. Replies: 6
    Last Post: 09-07-2017, 09:48 AM
  3. [SOLVED] Grab data according to value
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-07-2014, 09:01 AM
  4. How to grab last updated data
    By sorhaishadow in forum Excel General
    Replies: 1
    Last Post: 11-05-2010, 11:08 PM
  5. grab data from one sheet and put it into another
    By ecrader in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2009, 07:22 PM
  6. How Do I Grab This Conditional Data
    By noyellatmonkeys in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-05-2008, 12:39 PM
  7. Excel vb help: How to grab the right Data
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-23-2005, 08:05 AM

Tags for this Thread

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