• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA IE Automation_ copy element from ID and paste in excel

Hi Experts,

Iam working on a project ''Automation IE'', need your help on the same to copy element from ID and paste it in excel. Any help greatly appreciated.


Below is the VBA code so far.
Code:
Sub KBOSS_ARN_Profile()
Set browser = New SHDocVw.InternetExplorer

browser.Visible = True
browser.navigate ("MyURL")
Set Post = .document.getElementById("ctl00_ContentPlaceHolder1_TrAgentDet")

For Each ele In Post.getElementsByTagName("td")
         Debug.Print ele.innerHTML
    
Sheets("Sheet1").Range("G5").Value = ele.innerHTML
        Range("G2").Select
        browser.Quit

end sub


Im able to navigate to webpage, copy element but my code is copying inner HTML code and pasting in Excel(Like below table)


Below is the output with my code

<table cellpadding="0" cellspacing="0" border="0" class="TableCls" style="width: 100%">
<tbody><tr>
<td class="trheader" colspan="2" align="center">&nbsp; Personal Details
</td>
</tr>
<tr>
<td class="TextCls" style="width: 35%">&nbsp; Agent
</td>
<td style="width: 65%">
<span id="ctl00_ContentPlaceHolder1_lbl_PD_AgentCode">ARN-5752</span>
</td>
</tr>
<tr>
<td class="TextCls" valign="top">&nbsp; Name
</td>
<td>
<span id="ctl00_ContentPlaceHolder1_lbl_PD_Name">D V Laxman Babu</span>
</td>
</tr>
<tr>




And below table is the output when i copy element manually as shown in below screenshot
Personal Details
AgentARN-12345
NameBABU
Address1H.No: 2 - 2 - 46
Address2Hotel Sri Ganesh
Address3Gandhi Chowk
CityKHAMMAM
StateTL
Country
Pin507003
Off.Phone
Res.Phonexxxxx
Mobile Noxxxxx
Fax



emlement.jpg
 
Last edited:
Hi !​
To paste any html table to an Excel worksheet, clipboardData object can be used as you can see with the samples from this forum …​
 
Not enough material but just see the samples from this forum (so you should understand why) or any other, whatever …​
 
Back
Top