Getting HTML link using Internet explorer with VBA excel (no code error but the results is wrong)

itspapap

Automating an Internet explorer process by using VBA excel. I am trying to get the first link in this classname 'datacell' with the th scope=row in html using the first 'a href' tag as my needed link . however the result im getting is the wrong link. Could anyone help me about this? There is no error in the code but only the results im getting

refer to the image link - Correct link is the black circled one but the result is red circled one

enter image description here

This is my VBA code:

         Set appIE = New InternetExplorerMedium
           With appIE
          .Visible = False
          .Visible = True
                 Set doc = appIE.document
                    For Each li In doc.getElementsByClassName("list")
                    
                    checkIfAttachment = li.innerHTML
                    
                    If InStr(checkIfAttachment, "No matches found") Then
                        ws.Cells(i, 6).Value = "Not in SFDC"
                    
                    Else
                    
                        Set childLi = Nothing
                        For Each childLi In doc.getElementsByClassName(" dataCell  ")
                            link = childLi.getElementsByTagName("a")(0)
                            'first link is the one we want
                            
                        Next childLi
                        
                        link = Replace(link, "https://sample.com", "")
                        link = Replace(link, "?srPos=0&srKp=00P", "")
                        .navigate baseSFDCDownloadLink & link
                        Do While .Busy = True Or .readyState <> 4: DoEvents: Loop
                        Application.Wait (Now + TimeValue("0:00:05"))
pfndesign

you don't need a loop for "datacell". I'm not familiar with VBA but something like this could work .

link = doc.getElementsByClassName(" dataCell ")(0).getElementsByTagName("a")(0)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

click on link text in internet explorer using vba

Excel VBA Error 462 With Internet Explorer

VBA: set HTML as Internet Explorer object ERROR

Automation Error Unspecified Error with Internet Explorer Object Excel VBA

Using Excel VBA to automate form filling in Internet Explorer

how to open link in internet explorer using html or any browser language?

getting js error "expected identifier" while using internet explorer

vba intercept internet explorer link click

VBA Internet Explorer Webpage Link Selection

Getting Excel Vba Error but code still working?

Toggle Internet Explorer Proxy from Excel VBA

Excel VBA Internet explorer click button with no ID

Change Internet Explorer encoding using VBA

How to click a button in Internet Explorer using VBA

Paste event listener on Internet Explorer getting wrong arguments

Extract html source code into excel using VBA

Select option using Excel Automation with Internet explorer

Excel cannot open links using Internet Explorer

why am i getting typemismatch error in phaser project, i am using internet explorer 10 to deploy the game?

Click link in Internet Explorer

Error in Excel VBA code

Excel VBA: How to copy value of a field from Internet Explorer

How to close an Internet Explorer instance inside an Excel VBA

Excel VBA - Difference Between CreateObject and New Internet Explorer

How to click the hyperlink (<a> tag) in Internet Explorer through Excel VBA?

Using AppendChild on an svg in Internet Explorer is doing the wrong thing

Getting wrong results using AND and OR conditionals in WHERE Clause

Getting contents of link into excel via VBA

Run my VBA code from a existing (opened) internet explorer page