Hello,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o> </o>
This code is designed to enter a search for UPCs at http://www.upcdatabase.com/itemform.asp. Then it copies the url of the search results page and pastes it in excel next to its matching UPC. The end result should be a column of UPC numbers and a column of urls.<o></o>
<o> </o>
But every time I run code, I receive the error:<o></o>
<o></o>
When I choose the debug option, this line is highlighted:<o></o>
<o></o>
Any ideas to fix my broken code?<o></o>
<o></o>
Thanks for your help,<o></o>
<o> </o>
Bub
P.S. Thanks, Norie, for helping me thus far.
<o></o>
<o> </o>
This code is designed to enter a search for UPCs at http://www.upcdatabase.com/itemform.asp. Then it copies the url of the search results page and pastes it in excel next to its matching UPC. The end result should be a column of UPC numbers and a column of urls.<o></o>
<o> </o>
But every time I run code, I receive the error:<o></o>
<o></o>
<o></o>Run-time error '91':<o></o>
Object variable or With block variable not set<o></o>
<o></o>
When I choose the debug option, this line is highlighted:<o></o>
<o></o>
<o></o>doc.all("upc").Value = rngUPC.Text<o></o>
<o></o>
Any ideas to fix my broken code?<o></o>
<o></o>
Thanks for your help,<o></o>
<o> </o>
Bub
P.S. Thanks, Norie, for helping me thus far.
Rich (BB code):
Rich (BB code):
Rich (BB code):
Sub Test()<o:p></o:p>
Dim IE As Object<o:p></o:p>
Dim doc As Object<o:p></o:p>
Dim frm As Object<o:p></o:p>
Dim rngUPC As Range<o:p></o:p>
<o:p> </o:p>
Set IE = CreateObject("InternetExplorer.Application")<o:p></o:p>
<o:p></o:p>
Set rngUPC = Range("A1")<o:p></o:p>
<o:p></o:p>
With IE<o:p></o:p>
<o:p></o:p>
While rngUPC.Value <> ""<o:p></o:p>
<o:p> </o:p>
.Navigate "http://www.upcdatabase.com/itemform.asp"<o:p></o:p>
<o:p> </o:p>
Do Until .ReadyState = 4: DoEvents: Loop<o:p></o:p>
<o:p></o:p>
Set doc = IE.Document<o:p></o:p>
<o:p></o:p>
Set frm = doc.forms("upcform")<o:p></o:p>
<o:p></o:p>
doc.all("upc").Value = rngUPC.Text<o:p></o:p>
<o:p></o:p>
frm.submit<o:p></o:p>
<o:p></o:p>
Do While IE.Busy: DoEvents: Loop<o:p></o:p>
Do While IE.ReadyState <> 4: DoEvents: Loop<o:p></o:p>
<o:p></o:p>
rngUPC.Offset(, 1) = doc.url<o:p></o:p>
<o:p></o:p>
Set rngUPC = rngUPC.Offset(1)<o:p></o:p>
<o:p></o:p>
Wend<o:p></o:p>
<o:p></o:p>
.Quit<o:p></o:p>
<o:p> </o:p>
End With<o:p></o:p>
<o:p></o:p>
Set IE = Nothing<o:p></o:p>
<o:p></o:p>
End Sub<o:p></o:p>