{"id":668,"date":"2012-11-27T18:52:05","date_gmt":"2012-11-27T18:52:05","guid":{"rendered":"http:\/\/www.bardecode.com\/en1\/?p=668"},"modified":"2017-04-24T09:48:05","modified_gmt":"2017-04-24T09:48:05","slug":"excel-vba-macro","status":"publish","type":"post","link":"https:\/\/www.bardecode.com\/en1\/excel-vba-macro\/","title":{"rendered":"Excel VBA Macro"},"content":{"rendered":"<p>Here&#8217;s some example code that you can use in an Excel VBA macro&#8230;<\/p>\n<p>Before you begin, make sure you have downloaded and installed the barcode reader sdk for windows, and run REGISTER.BAT as administrator in the bin folder.<\/p>\n<pre>Set Barcode = CreateObject(\"SoftekBarcodeCOM.Barcode\")\r\n' Set the license key here\r\nBarcode.LicenseKey = \"MY LICENSE KEY\"\r\nBarcode.ScanDirection = 15\r\n' Select the barcode type to search for\r\nBarcode.ReadCode128 = True\r\nBarcode.ReadCode25 = True\r\nBarcode.ReadEAN13 = True\r\nBarcode.ReadEAN8 = True\r\nBarcode.ReadUPCA = True\r\nBarcode.ReadUPCE = True\r\nBarcode.ReadCode39 = True\r\nFILE_NAME = \"C:\\PATH\\TO\\MY\\IMAGE.TIF\"\r\nBarcode.ScanBarCode (FILE_NAME)\r\nnBarCode = Barcode.BarCodeCount\r\nIf (nBarCode &lt;= -6) Then\r\n\u00a0 \u00a0 'Evaluation expired or is not valid\r\n\u00a0 \u00a0 MsgBox (\"License error\")\r\nElseIf (nBarCode &lt; 0) Then\r\n\u00a0 \u00a0 MsgBox (\"Error reading barcode\")\r\nElseIf (nBarCode = 0) Then\r\n\u00a0 \u00a0 MsgBox (\"No barcode found\")\r\nElse\r\n\u00a0 \u00a0 strBarcode = Barcode.barstring(1)\r\nEnd If<\/pre>\n<p>You&#8217;ll need to modify the FILE_NAME to some file on your system and do something withthe strBarcode result, but this should get you up and working.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s some example code that you can use in an Excel VBA macro&#8230; Before you begin, make sure you have downloaded and installed the barcode reader sdk for windows, and run REGISTER.BAT as administrator in the bin folder. Set Barcode = CreateObject(&#8220;SoftekBarcodeCOM.Barcode&#8221;) &#8216; Set the license key here Barcode.LicenseKey = &#8220;MY LICENSE KEY&#8221; Barcode.ScanDirection =<\/p>\n<p><a href=\"https:\/\/www.bardecode.com\/en1\/excel-vba-macro\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":324,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[19,146,193,195,131,107,194],"class_list":["post-668","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-development-kits","tag-barcode","tag-example","tag-excel","tag-macro","tag-reader","tag-setting","tag-vba"],"_links":{"self":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/668"}],"collection":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/comments?post=668"}],"version-history":[{"count":4,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/668\/revisions"}],"predecessor-version":[{"id":2296,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/posts\/668\/revisions\/2296"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media\/324"}],"wp:attachment":[{"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/media?parent=668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/categories?post=668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bardecode.com\/en1\/wp-json\/wp\/v2\/tags?post=668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}