Oct-01-2019, 03:29 AM
Hi Forum,
I'm trying to scrape some data regularly from the company CRM (Customer Relationship Management) tool that contains all the data entered & produces reports.
I'm using some adapted code & I'm fairly new to the process.
I'm also using MS Excel with VBA to do this.
Firstly, the code below will open the CRM so I thought it must then be able to scrape some content?
I've gone to the source & found the correct class to extract some data, it's where I need to split this into One Item at a time & paste into Excel is where I'm stuck.
Because I've reused some code that maybe won't fit my purpose, I've included the HTML where I've got my class from so someone could maybe help here.
Run Time Error '462'
The remote server machine does not exist or is unavailable
My code is below:
I'm trying to scrape some data regularly from the company CRM (Customer Relationship Management) tool that contains all the data entered & produces reports.
I'm using some adapted code & I'm fairly new to the process.
I'm also using MS Excel with VBA to do this.
Firstly, the code below will open the CRM so I thought it must then be able to scrape some content?
I've gone to the source & found the correct class to extract some data, it's where I need to split this into One Item at a time & paste into Excel is where I'm stuck.
Because I've reused some code that maybe won't fit my purpose, I've included the HTML where I've got my class from so someone could maybe help here.
Run Time Error '462'
The remote server machine does not exist or is unavailable
My code is below:
Quote:Sub scrape_crm_open()
' declare the variables
Dim ieObj As InternetExplorer
Dim htmlEle As IHTMLElement
Dim i As Integer
' initialize i to one
i = 1
' create and get access to an instance of IE
Set ieObj = New InternetExplorer
ieObj.Visible = True
ieObj.navigate "http://our_co_crm/main.aspx#"
' give the webpage some time to load all content
Application.Wait Now + TimeValue("00:00:05")
' loop through all the rows in the table
For Each htmlEle In ieObj.Document.getElementsByClassName("ms-crm-List_Data")(0).getElementsByTagName("tr") 'Error is here
With ActiveSheet
.Range("A" & i).Value = htmlEle.Children(0).textContent
.Range("B" & i).Value = htmlEle.Children(1).textContent
.Range("C" & i).Value = htmlEle.Children(2).textContent
.Range("D" & i).Value = htmlEle.Children(3).textContent
.Range("E" & i).Value = htmlEle.Children(4).textContent
End With
i = i + 1
Next htmlEle
End Sub