Last active
December 31, 2019 15:41
-
-
Save larsschenk/70da0380cabb1dc76c194cc7bcea89c8 to your computer and use it in GitHub Desktop.
Visual Basic for Application examples using the ActiveBarcode REST API with Excel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' There is one Button (CommandButton1) and one Image (Image1) in the sheet. | |
' If you click on the button, the value of the active cell is displayed as barcode in the image. | |
' Since LoadPicture cannot use PNG, JPG is used here. | |
' | |
Private Declare Function URLDownloadToFile Lib "urlmon" _ | |
Alias "URLDownloadToFileA" _ | |
(ByVal pCaller As Long, _ | |
ByVal szURL As String, _ | |
ByVal szFileName As String, _ | |
ByVal dwReserved As Long, _ | |
ByVal lpfnCB As Long) As Long | |
Private Sub CommandButton1_Click() | |
strURL = "https://api.activebarcode.net/v1/jpg?access=YOUR-KEY-HERE" | |
strParam = "&code=CODE128&text=" & Cells(ActiveCell.Row, ActiveCell.Column).Value | |
strFile = Environ("TEMP") & "\barcodeapi-temp.jpg" | |
result = URLDownloadToFile(0, strURL & strParam, strFile, 0, 0) | |
Image1.Picture = LoadPicture(strFile) | |
Kill strFile | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment