3 ms·
Buy a cheap hand held battery operated wireless barcode scanner (cheap on AliExpress). These work really well for scanning stacks of books... pick the book up,
by rbobby 5y ago
Buy a cheap hand held battery operated wireless barcode scanner (cheap on AliExpress). These work really well for scanning stacks of books... pick the book up, zap, put the book down. You have to config the scanner to operate in "keyboard" mode or some such... basically what you scan gets typed as if from a keyboard.
I used a simple Excel macro for data capture and lookup. Basically when a cell changed (book was scanned) it would request the book data from outpan.com. If outpan didn't know the upc beep and return to the cell, otherwise decode the response (json) and populate the spreadsheet row.
Here's the excel macro (why I used the B column instead of the A column is a longer story):
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count <> 1 Then
Exit Sub
End If
If Application.Intersect(Range("B2:B99999"), Range(Target.Address)) Is Nothing Then
Exit Sub
End If
Dim Ean
Ean = CStr(Target.value)
Dim Url
Url = "https://api.outpan.com/v2/products/" + Ean + "?apikey=[haha get your own key haha]"
Dim HttpRequest
Set HttpRequest = CreateObject("MSXML2.XMLHTTP")
HttpRequest.Open "GET", Url, False
HttpRequest.Send
Set json = New VbsJson
Set o = json.Decode(HttpRequest.ResponseText)
If Not IsEmpty(o("error")) Then
Beep
ActiveCell.Offset(-1, 0).Select
Else
booktitle = o("name")
If IsNull(booktitle) Then
Beep
ActiveCell.Offset(-1, 0).Select
Else
If IsVarArrayEmpty(o("attributes")) Then
Author = ""
PublishedOn = ""
Else
If IsEmpty(o("attributes")("Author(s)")) Then
Author = ""
Else
Author = o("attributes")("Author(s)")
End If
If IsEmpty(o("attributes")("Publication Date")) Then
PublishedOn = ""
Else
PublishedOn = o("attributes")("Publication Date")
End If
End If
Cells(Target.Row, Target.Column - 1).value = Cells(Target.Row - 1, Target.Column - 1).value
Cells(Target.Row, Target.Column + 1).value = booktitle
Cells(Target.Row, Target.Column + 2).value = Author
Cells(Target.Row, Target.Column + 3).value = PublishedOn
End If
End If
End Sub
Function IsVarArrayEmpty(anArray As Variant)
Dim i As Integer
If IsObject(anArray) Then
IsVarArrayEmpty = False
Else
On Error Resume Next
i = UBound(anArray, 1)
If Err.Number = 0 Then
If i < 0 Then
IsVarArrayEmpty = True
Else
IsVarArrayEmpty = False
End If
Else
IsVarArrayEmpty = True
End If
End If
End Function
edit: you will need VbsJson from http://demon.tw/my-work/vbs-json.html http://demon.tw/my-work/vbs-json.html (why that's a chinese page I don't know all I know was it was a single file json parser that was easy to work with for this).
edit2: I used this solution to scan and log 750 books in a couple of hours? Maybe 3? It went pretty quick.
- GianFabien 5y agoI'd like to commend you for publishing your working code. This is a great help for somebody wishing to replicate your excellent work.