+ Reply to Thread
Results 1 to 4 of 4

doc.GetElementsByClassname with weirdly formatted classnames

Hybrid View

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    doc.GetElementsByClassname with weirdly formatted classnames

    Hi all,

    I'm loading a HTTP response into a html document in VBA. I can get responses by saying
    debug.print doc.GetElementsByTagname("a")(0).innertext
    for example, but if I want to get something by classname I don't quite know how to call them as they're called like below:

    \"a-link-normal\"
    \"a-size-base
    \"a-size-mini
    \"a-expander-header

    using the below doesn't give me anything - and I don't believe I can use wildcards.
    debug.print doc.getelementsbyclassname("\""a-link-normal\").length
    Does anyone have any pointers?
    Thanks,

    Jasper

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: doc.GetElementsByClassname with weirdly formatted classnames

    My wieldiest guess is treat it like JavaScript does, round double quote with a single quote and Vice versa. I do not know if you can use a escape character.

  3. #3
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: doc.GetElementsByClassname with weirdly formatted classnames

    I actually solved it by using a very rude approach - I just do this:
    doc.body.innerHTML = Replace(http.responseText, "\" & Chr(34), Chr(34))
    Which makes it not as neat as could be, but allows me to get the data I want by using the newly-formed, long class names.

  4. #4
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: doc.GetElementsByClassname with weirdly formatted classnames

    thanks for the swift reply AB33 - how would I implement that though?
    as in VBA I still get the \ before the quote as part of the name:

    debug.print doc.getElementsByTagName("a")(1).classname
    \"a-link-normal\"

+ 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. Getting data from webpage using "classnames" that are the same
    By WisconsinJohn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2015, 04:25 PM
  2. [SOLVED] IE.Document.getElementsByClassName Object not supporting property or method
    By kamelkid2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2014, 08:17 AM
  3. Pasting weirdly
    By frank35 in forum Excel General
    Replies: 3
    Last Post: 12-11-2013, 11:17 AM
  4. [SOLVED] getElementsByClassName Wildcard Character?
    By killerkoz17 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-08-2013, 08:10 AM
  5. [SOLVED] getElementsByClassName from Yammer causing Run-time error 91
    By gerainta in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-20-2013, 05:49 AM
  6. Error Handling behaving weirdly
    By firefly2k8 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-10-2010, 10:20 AM
  7. Range missing its target area weirdly
    By Konrad Viltersten in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-23-2006, 12:45 AM

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