Založ si blog

ModulBarcode

Attribute VB_Name = „ModulBarcode“
‚ Barcode symbol creation by VBA
‚ Author: alois zingl
‚ Version: V1.1 jan 2016
‚ Copyright: Free and open-source software
‚ http://members.chello.at/~easyfilter/barcode.html
‚ Description: the indention of this library is a short and compact implementation to create barcodes
‚ of Code 128, Data Matrix, (micro) QR or Aztec symbols so it could be easily adapted for individual requirements.
‚ The Barcode is drawn as shape in the cell of the Excel sheet.
‚ The smallest bar code symbol fitting the data is automatically selected,
‚ but no size optimization for mixed data types in one code is done.
‚ Functions:
‚ DataMatrix(text As String, Optional rectangle As Integer)
‚ QuickResponse(text As String, Optional level As String = „L“, Optional version As Integer = 1)
‚ Aztec(text As String, Optional security As Integer, Optional layers As Integer = 1)
‚ Code128(text As String)

Option Explicit

‚ add description to user defined barcode functions
Private Sub Workbook_Open()
ReDim arg(0) As String
arg(0) = „text to encode“
Application.MacroOptions macro:=“Code128″, Description:=“Draw Code 128 barcode“, Category:=“Barcode“, ArgumentDescriptions:=arg
Application.MacroOptions macro:=“DataMatrix“, Description:=“Draw DataMatrix barcode“, Category:=“Barcode“, ArgumentDescriptions:=arg
ReDim Preserve arg(2)
arg(1) = „percentage of checkwords (1..90)“ + vbCrLf + „number, optional, default 23%“
arg(2) = „minimum number of layers (0-32)“ + vbCrLf + „number, optional, default 1“ + vbCrLf + „set to 0 for Aztec rune“
Application.MacroOptions macro:=“Aztec“, Description:=“Draw Aztec barcode“, Category:=“Barcode“, ArgumentDescriptions:=arg
arg(1) = „security level „“LMQH“““ + vbCrLf + „low, medium, quartile, high“ + vbCrLf + „letter, optional, default L“
arg(2) = „minimum version size(-3..40)“ + vbCrLf + „number, optional, default 1“ + vbCrLf + „MircoQR M1:-3, M2:-2, M3:-1, M4:0″
Application.MacroOptions macro:=“QRCode“, Description:=“Draw QR code“, Category:=“Barcode“, ArgumentDescriptions:=arg
End Sub

‚ convert UTF-16 (Windows) to UTF-8
Public Function utf16to8(text As String) As String
Dim i As Integer, c As Long
utf16to8 = text
For i = Len(text) To 1 Step -1
c = AscW(Mid(text, i, 1)) And 65535
If c > 127 Then
If c > 4095 Then
utf16to8 = Left(utf16to8, i – 1) + Chr(224 + c \ 4096) + Chr(128 + (c \ 64 And 63)) + Chr(128 + (c And 63)) & Mid(utf16to8, i + 1)
Else
utf16to8 = Left(utf16to8, i – 1) + Chr(192 + c \ 64) + Chr(128 + (c And 63)) & Mid(utf16to8, i + 1)
End If
End If
Next i
End Function

‚update all barcodes in active sheet
Public Sub updateBarcodes()
Attribute updateBarcodes.VB_Description = „Updates all barcode shapes of the actual sheet.“
Attribute updateBarcodes.VB_ProcData.VB_Invoke_Func = „q\n14“
Dim shp As Shape, bc As Variant, str As String
On Error Resume Next
For Each shp In ActiveSheet.Shapes ‚ delete all lost barcode shapes
If shp.Type = msoAutoShape Then
str = LCase(shp.AlternativeText)
For Each bc In Array(„aztec“, „code128“, „datamatrix“, „qrcode“)
If Left(str, Len(bc)) = bc Then
shp.Title = „“ ‚ force redraw
If InStr(LCase(Range(shp.Name).Formula), bc) = 0 Then shp.Delete
Exit For
End If
Next bc
End If
Next shp
Application.CalculateFull ‚ refresh all barcodes
Kanji
End Sub

‚ read/write kanji conversion string from/to file
Public Sub Kanji()
Dim p As Variant, s As Worksheet, k1 As String, c As Long
Const k = „kanji“ ‚ property name
For Each s In Application.ThisWorkbook.Worksheets
For Each p In s.CustomProperties ‚ look for kanji conversion string
If p.Name = k Then If Len(p.Value) > 10000 Then k1 = p.Value
Next p
Next s
ChDir Application.ThisWorkbook.Path
If k1 = „“ Then ‚ not found, get from file
p = Application.GetOpenFilename(„Excel Files (*.xlsm), *.xlsm“, 1, „Read Kanji Conversion String for QRCodes from ‚barcode.xlsm'“)
If p <> False Then
Application.ScreenUpdating = False
With Workbooks.Open(p, 0, True)
For Each s In .Worksheets
For Each p In s.CustomProperties ‚ look for kanji conversion string
If p.Name = k Then If Len(p.Value) > 10000 Then k1 = p.Value
Next p
Next s
.Close
End With
Application.ScreenUpdating = True
If Len(k1) < 10000 Or (Len(k1) And 1) Then MsgBox „No Kanji conversion string for QRCodes found in Excel file.“
For Each s In Application.ThisWorkbook.Worksheets
c = 0
For Each p In s.CustomProperties ‚ look for kanji conversion string
If p.Name = k Then p.Value = k1: c = 1
Next p
If c = 0 Then s.CustomProperties.Add k, k1
Next s
End If
End If
End Sub

ModulQRcode

17.06.2024

Attribute VB_Name = „ModulQRcode“ Option Explicit Dim mat() As Byte ‚ matrix of QR ‚ QR Code 2005 bar code symbol creation according ISO/IEC 18004:2006 ‚ param text to encode ‚ param level optional: quality level LMQH ‚ param version optional: minimum version size (-3:M1, -2:M2, .. 1, .. 40) ‚ creates QR and micro QR bar code symbol as shape in [...]

ModulDataMatrix

17.06.2024

Attribute VB_Name = „ModulDataMatrix“ Option Explicit ‚ creates Data Matrix barcode symbol as shape in Excel cell. ‚ param text to encode ‚ param rectangle boolean, default autodetect on cell dimension ‚ Data Matrix symbol creation according ISO/IEC 16022:2006 Public Function DataMatrix(text As String, Optional rectangle As Integer = -2) As String Attribute [...]

ModulCode128

17.06.2024

Attribute VB_Name = „ModulCode128“ Option Explicit ‚ Code 128 symbol creation according ISO/IEC 15417:2007 Public Function Code128(text As String) As String Attribute Code128.VB_Description = „Draw Code 128 barcode“ Attribute Code128.VB_ProcData.VB_Invoke_Func = “ \n18″ On Error GoTo failed If Not TypeOf Application.Caller Is Range Then Err.Raise 513, [...]

V centre Soulu vrazilo auto do chodcov, zahynulo najmenej deväť ľudí

01.07.2024 18:24

Vodič tvrdil, že jeho auto náhle zrýchlilo. Polícia okolnosti nehody vyšetruje.

Základná škola Parchovany

V prípade samovraždy deviataka v Parchovanoch nastal zvrat, obvinili spolužiačku

01.07.2024 17:20

Polícia potvrdila, že vyšetrovanie v danej veci doposiaľ nebolo ukončené.

Trump

Exprezidenti USA majú istú imunitu, rozhodol najvyšší súd USA. Trumpov prípad viazne

01.07.2024 16:53, aktualizované: 17:13

Spor sa teraz vracia k federálnej sudkyni, ktorá kvôli prerokúvaniu Trumpovej námietky pozastavila proces.

SAV, Slovenská akadémia vied

SAV dostane od vlády o takmer 55 miliónov eur viac. Na čo ich plánuje využiť?

01.07.2024 16:43

Ide o desaťpercentný nárast v porovnaní s pôvodným rozpočtom.

Štatistiky blogu

Počet článkov: 17
Celková čítanosť: 45365x
Priemerná čítanosť článkov: 2669x

Autor blogu

Kategórie