Status
Not open for further replies.

bubububub

New Member
Joined
Jul 2, 2010
Messages
18
Hello,

I have a large column of UPC numbers I wish to identify. 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 2007 next to its matching UPC. The end result should be a column of UPC numbers and a column of urls.

But every time I run code, I receive the error:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>

<TABLE class=MsoNormalTable style="WIDTH: 100%; mso-padding-alt: 4.5pt 4.5pt 4.5pt 4.5pt; mso-cellspacing: 0in; mso-yfti-tbllook: 1184" cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"><TD style="BORDER-RIGHT: #ece9d8 1pt inset; PADDING-RIGHT: 4.5pt; BORDER-TOP: #ece9d8 1pt inset; PADDING-LEFT: 4.5pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4.5pt; BORDER-LEFT: #ece9d8 1pt inset; PADDING-TOP: 4.5pt; BORDER-BOTTOM: #ece9d8 1pt inset"></TD></TR><TR style="mso-yfti-irow: 1; mso-yfti-lastrow: yes"><TD style="BORDER-RIGHT: #ece9d8 1pt inset; PADDING-RIGHT: 4.5pt; BORDER-TOP: #ece9d8 1pt inset; PADDING-LEFT: 4.5pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4.5pt; BORDER-LEFT: #ece9d8 1pt inset; PADDING-TOP: 4.5pt; BORDER-BOTTOM: #ece9d8 1pt inset">Run-time error '91':
Object variable or With block variable not set <o:p></o:p>

</TD></TR></TBODY></TABLE>[/Quote]

When I choose the debug option, this line is highlighted:
<o:p></o:p>
<TABLE class=MsoNormalTable style="WIDTH: 100%; mso-padding-alt: 4.5pt 4.5pt 4.5pt 4.5pt; mso-cellspacing: 0in; mso-yfti-tbllook: 1184" cellSpacing=0 cellPadding=0 width="100%" border=0><TBODY><TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"><TD style="BORDER-RIGHT: #ece9d8 1pt inset; PADDING-RIGHT: 4.5pt; BORDER-TOP: #ece9d8 1pt inset; PADDING-LEFT: 4.5pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4.5pt; BORDER-LEFT: #ece9d8 1pt inset; PADDING-TOP: 4.5pt; BORDER-BOTTOM: #ece9d8 1pt inset">doc.all("upc").Value = rngUPC.Text <o:p></o:p>
</TD></TR></TBODY></TABLE>


Any ideas to fix my broken code?

<o:p></o:p>

Please note: This code appears to work if the column has only 1 number. When applied to a column with many numbers, however, the error occurs.<o:p></o:p>

Thanks for your help,

Bub
P.S. Thanks, Norie, for helping me thus far.<o:p></o:p>
Code:
<o:p></o:p>[/SIZE][/FONT][/COLOR]
[COLOR=black][FONT=Courier New]Sub Test()<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]Dim IE As Object<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]Dim doc As Object<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]Dim frm As Object<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]Dim rngUPC As Range<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]    Set IE = CreateObject("InternetExplorer.Application")<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]    Set rngUPC = Range("A1")<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]    With IE<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]        While rngUPC.Value <> ""<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            .Navigate "[URL="http://www.upcdatabase.com/itemform.asp"][COLOR=blue]http://www.upcdatabase.com/itemform.asp[/COLOR][/URL]"<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            Do Until .ReadyState = 4: DoEvents: Loop<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            Set doc = IE.Document<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            Set frm = doc.forms("upcform")<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            doc.all("upc").Value = rngUPC.Text<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            frm.submit<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            Do While IE.Busy: DoEvents: Loop<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            Do While IE.ReadyState <> 4: DoEvents: Loop<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            rngUPC.Offset(, 1) = doc.url<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]            Set rngUPC = rngUPC.Offset(1)<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]        Wend<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]        .Quit<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]    End With<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]    Set IE = Nothing<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New] <o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Courier New]End Sub<o:p></o:p>[/FONT][/COLOR]

[FONT=Calibri][SIZE=3]
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Bub

The code worked fine for me with multiple UPCs, the only thing I can think could possibly be causing is something to do with your browser or connectivity.

Can you post the data that is causing the error? I only tested using some random nos.

Though the error you describe doesn't sound as though it's caused by erroneous data.
 
Upvote 0
Norie,

Thanks for the help again.

Here are the first ten UPCs:
<TABLE style="WIDTH: 116pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=154 border=0><COLGROUP><COL style="WIDTH: 116pt; mso-width-source: userset; mso-width-alt: 5632" width=154><TBODY><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; WIDTH: 116pt; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" width=154 height=20>000000000007</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000008</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000011</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000011</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000011</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000022</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000100</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000111</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000111</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="BORDER-RIGHT: #ece9d8; BORDER-TOP: #ece9d8; BORDER-LEFT: #ece9d8; BORDER-BOTTOM: #ece9d8; HEIGHT: 15pt; BACKGROUND-COLOR: transparent" height=20>000000000111</TD></TR></TBODY></TABLE>

Bub
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,218,899
Messages
6,145,085
Members
450,590
Latest member
Naneng

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top