#1
|
|||
|
|||
Excel 2003 VBA Help copying innertext
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. Last edited by macropod; 04-05-2014 at 08:54 PM. Reason: Added code structure |
#2
|
||||
|
||||
I'm not much on web-site querying via VBA, but I note your 'Select Case' construct has two case tests for 'title', which seems a little odd .
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks man. Yea I just didn't realize my typo there. I meant to put description for the second lol.
|
Tags |
copy innertext, excel 2003 |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copying data from Project to Excel | OTPM | Project | 13 | 12-20-2013 10:25 AM |
Copying a variable size table from Excel via VBA | -=bb=- | PowerPoint | 13 | 06-05-2013 09:01 AM |
Copying and pasting from Excel | Lorna B | Word | 1 | 03-20-2012 11:58 PM |
Copying text from Excel to Word | Fossils13 | Office | 1 | 02-22-2010 08:39 PM |
MS Excel 2004 for Mac - copying dates between documents | BCRenton | Excel | 4 | 11-10-2009 07:28 AM |