图书清单 - 使用Excel VBA条形码查找从亚马逊获取图书详细信息

haw*_*eye 11 excel vba barcode excel-vba amazon-web-services

我有一个条形码阅读器和一堆书.对于每本书,我想在Excel电子表格中列出书名和作者.

我的观点是,一些连接到Amazon Web服务的VBA代码会使这更容易.

我的问题是 - 以前没有人这样做过吗?你能指点我最好的例子吗?

Dr.*_*ius 16

我认为这是一个简单的谷歌搜索,但结果比我预期更困难.

事实上,我无法找到基于VBA ISBN的程序来从网上获取图书数据,所以决定做一个.

这是一个使用xisbn.worldcat.org服务的VBA宏.这里的例子..这些服务是免费的,不需要身份验证.

为了能够运行它,您应该在Tools-> References(在VBE窗口中)检查"Microsoft xml 6.0"库.

此宏从当前单元格中获取ISBN(10位数),并使用作者和标题填充以下两列.您应该能够轻松地遍历整列.

代码已经过测试(好吧,有点),但那里没有错误检查.

 Sub xmlbook()
 Dim xmlDoc As DOMDocument60
 Dim xWords As IXMLDOMNode
 Dim xType As IXMLDOMNode
 Dim xword As IXMLDOMNodeList
 Dim xWordChild As IXMLDOMNode
 Dim oAttributes As IXMLDOMNamedNodeMap
 Dim oTitle As IXMLDOMNode
 Dim oAuthor As IXMLDOMNode
 Set xmlDoc = New DOMDocument60
 Set xWords = New DOMDocument60
 xmlDoc.async = False
 xmlDoc.validateOnParse = False
 r = CStr(ActiveCell.Value)

 xmlDoc.Load ("http://xisbn.worldcat.org/webservices/xid/isbn/" _
              + r + "?method=getMetadata&format=xml&fl=author,title")

 Set xWords = xmlDoc

     For Each xType In xWords.ChildNodes
         Set xword = xType.ChildNodes
         For Each xWordChild In xword
             Set oAttributes = xWordChild.Attributes
             On Error Resume Next
             Set oTitle = oAttributes.getNamedItem("title")
             Set oAuthor = oAttributes.getNamedItem("author")
             On Error GoTo 0
         Next xWordChild
     Next xType
  ActiveCell.Offset(0, 1).Value = oTitle.Text
  ActiveCell.Offset(0, 2).Value = oAuthor.Text
 End Sub
Run Code Online (Sandbox Code Playgroud)

由于他们新的"简单"认证协议,我没有通过亚马逊...

  • +1是消费Web服务的好例子! (2认同)