Hello everyone, I'm still new to VBA and trying to figure out how to copy the innertext from the description. After I get VBA to go out to IE navigate to
www.lenox.com and search a sku number. I get no errors in my code below but I'm doing something wrong. I can't figure out how to get the innertext to copy into a cell. here is my code below. It always leaves it blank on me. Hopefully someone can help me out. I'd really appreciate it.
Code:
Sub Lenoxtest()
Dim oForm As Object
Dim SKU As String
Dim URL As String
Dim objIE As Object
Dim eRow As Long
Dim ele As Object
Set sht = Sheets("Sheet1")
RowCount = 1
sht.Range("A" & RowCount) = "content"
sht.Range("B" & RowCount) = "description"
Set objIE = CreateObject("InternetExplorer.Application")
SKU = InputBox(" Enter Sku #. eg, 845123")
With objIE
.Visible = True
.navigate "http://www.Lenox.com"
While objIE.Busy And objIE.ReadyState <> 4: DoEvents: Wend
Set objIE = .document.body
Set oForm = objIE.getElementsbyTagname("Form")
Set oForm = oForm(0)
Set oInput = oForm.document.getElementByID("keywords")
Set oBtn = oForm.document.getElementsbyTagname("input")
Set oBtn = oBtn(1)
oInput.Value = SKU
oBtn.Click
oForm.submit
For Each ele In .document.all
Select Case ele.classname
Case "title"
RowCount = RowCount + 1
Case "title"
sht.Range("A" & RowCount) = ele.innertext
End Select
Next ele
End With
Set objIE = Nothing
End Sub
here is an example of what it does when you enter a Sku #
http://www.lenox.com/dining/dinnerwa...x?R=25019&kf=1
takes you to a search result like this and then I'm trying to copy the description into excel.