Giter VIP home page Giter VIP logo

qrcodelibvba's Introduction

QRCodeLibVBA

QRCodeLibVBAは、Excel VBAで書かれたQRコード生成ライブラリです。
JIS X 0510:2004に基づくモデル2コードシンボルを生成します。

特徴

  • 数字・英数字・8ビットバイト・漢字モードに対応しています
  • 分割QRコードを作成可能です
  • BMP、EMF、GIF、PNG、SVG、TIFFファイルに保存可能です
  • QRコードをIPictureDispオブジェクトとして取得可能です
  • 配色を指定可能です
  • 文字セットを指定可能です
  • QRコードをクリップボードに保存可能です

クイックスタート

QRCodeLib.xlamを参照設定してください。

使用方法

例1.最小限のコードを示します

Dim sbls As Symbols
Set sbls = CreateSymbols()
sbls.AppendText "012345abcdefg"

Dim pict As stdole.IPictureDisp
Set pict = sbls(0).GetPicture()

例2.誤り訂正レベルを指定する

CreateSymbols関数の引数に、ErrorCorrectionLevel列挙型の値を設定してSymbolsオブジェクトを生成します。

Dim sbls As Symbols
Set sbls = CreateSymbols(ErrorCorrectionLevel.L) ' 7%
Set sbls = CreateSymbols(ErrorCorrectionLevel.M) ' 15%(default)
Set sbls = CreateSymbols(ErrorCorrectionLevel.Q) ' 25%
Set sbls = CreateSymbols(ErrorCorrectionLevel.H) ' 30%

例3.型番の上限を指定する

CreateSymbols関数のmaxVer引数を設定してSymbolsオブジェクトを生成します。

Dim sbls As Symbols
Set sbls = CreateSymbols(maxVer:=10)

例4.文字セットを指定する

CreateSymbols関数のcharsetName引数を設定してSymbolsオブジェクトを生成します。 (ADODB.Stream に依存しています。使用可能な文字セットはレジストリ[HKEY_CLASSES_ROOT\MIME\Database\Charset]を確認してください。)

既定値はShift_JISです。UTF-8の設定例を以下に示します。

Dim sbls As Symbols
Set sbls = CreateSymbols(charsetName:="UTF-8")

例5.分割QRコードを作成する

CreateSymbols関数の引数を設定してSymbolsオブジェクトを生成します。型番の上限を指定しない場合は、型番40を上限に分割されます。

型番1を上限に分割し、各QRコードのIPictureDispオブジェクトを取得する例を示します。

Dim sbls As Symbols
Set sbls = CreateSymbols(maxVer:=1, allowStructuredAppend:=True)
sbls.AppendText "abcdefghijklmnopqrstuvwxyz"
    
Dim pict As stdole.IPictureDisp
Dim sbl As Symbol
    
For Each sbl In sbls
    Set pict = sbl.GetPicture()
Next

例6.画像形式を指定してIPictureDispオブジェクトを取得する

GetPictureメソッドのpicType引数を設定します。

Dim sbls As Symbols
Set sbls = CreateSymbols()
sbls.AppendText "012345abcdefg"

Dim pict As stdole.IPictureDisp

' Bitmap
Set pict = sbls(0).GetPicture(picType:=Bitmap)

' Metafile
Set pict = sbls(0).GetPicture(picType:=EnhMetaFile)

例7.ファイルへ保存する

SymbolクラスのSaveAsメソッドを使用します。

Dim sbls As Symbols
Set sbls = CreateSymbols()
sbls.AppendText "012345abcdefg"
    
' monochrome BMP
sbls(0).SaveAs "filename"

' true color BMP
sbls(0).SaveAs "filename", fmt:=fmtTrueColor

' EMF
sbls(0).SaveAs "filename", fmt:=fmtEMF

' GIF
sbls(0).SaveAs "filename", fmt:=fmtGIF

' transparent GIF
sbls(0).SaveAs "filename", fmt:=fmtGIF, bkStyle:=bkTransparent

' monochrome PNG
sbls(0).SaveAs "filename", fmt:=fmtPNG

' true color PNG 
sbls(0).SaveAs "filename", fmt:=fmtPNG + fmtTrueColor

' transparent PNG 
sbls(0).SaveAs "filename", fmt:=fmtPNG + fmtTrueColor, bkStyle:=bkTransparent

' SVG
sbls(0).SaveAs "filename", fmt:=fmtSVG

' monochrome TIFF
sbls(0).SaveAs "filename", fmt:=fmtTIFF

' true color TIFF
sbls(0).SaveAs "filename", fmt:=fmtTIFF + fmtTrueColor

' bilevel TIFF
sbls(0).SaveAs "filename", fmt:=fmtTIFF + fmtBilevel

' 10 pixels per module
sbls(0).SaveAs "filename", moduleSize:=10
    
' specify foreground and background colors
sbls(0).SaveAs "filename", foreRgb:="#0000FF", backRgb:="#FFFF00"

例8.クリップボードへ保存する

SymbolクラスのSetToClipBoardメソッドを使用します。

Dim sbls As Symbols
Set sbls = CreateSymbols()
sbls.AppendText "012345abcdefg"

' Bitmap 
sbls(0).SetToClipBoard

' Metafile
sbls(0).SetToClipboard fmt:=fmtEMF

例9.型番を固定して画像サイズを一定にする

CreateSymbols関数のmaxVer引数とfixedSize引数を設定してSymbolsオブジェクトを生成します。
常にmaxVer引数で指定された型番で生成されます。
型番10に固定する例を以下に示します。

Dim sbls As Symbols
Set sbls = CreateSymbols(maxVer:=10, fixedSize:=True)
sbls.AppendText "Hello World"

qrcodelibvba's People

Contributors

yas78 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qrcodelibvba's Issues

GetPictureのEMF対応

難しいのを承知でリクエスト(というか可能なのかも含めてご確認)したいのですが、
EMF版のGetPictureの実装などは難しいでしょうか?

というのは、

    With Me.imgQr
        .PictureAlignment = fmPictureAlignmentCenter
        .PictureSizeMode = fmPictureSizeModeZoom
        .Picture = sbls(0).GetPicture(MODULE_SIZE)
    End With

というサンプルの方法を試してみたのですが、20mm角程度でVersion30以降などの細かいQRを
印字したいとき、現状の実装ですとアンチエイリアシングがうまく切れず、印字品質に優れません。
(アンチエイリアスによるつぶれが気になる)
検証環境:Microsoft Excel 2016

こちらで試したこととしては、GetMonochromeBMPの実装を参考に、
1bpp画像を送るGetPictureを試作もしてみたのですが、それでもアンチエイリアスが切れず、とい状況です。

宜しくお願い致します。

漢字モードで簡体字の文字セットGB2312に対応してほしい

こんにちは、あなたのツールは素晴らしいです、ありがとう!
残念ながら、使用中に**語が認識できないことがわかりましたが、**語を認識できるバージョンを提供していただけますか?
私は**から来ました、私の電子メール:[email protected]。(Translated by google)

你好,你的工具非常优秀,感谢!
遗憾的是,我在使用过程中发现汉字无法识别,你能提供能识别汉字的版本吗?
我来自**,我的E-mail:[email protected]

Problem encoding multilingual strings containing Cyrillic letters

Hello
I need to encode a string that contains mixed symbols including Latin, Cyrillic letters, digits, and special characters.
I faced some problem encoding multilingual strings containing Cyrillic letters. If a string starts with a Cyrillic letter the QR code is generated correctly. Also if up to 6 first symbols are non-Cyrillic there's no problem encoding the whole string. However if more than 6 first symbols are non-Cyrillic the subsequent Cyrillic letters are no longer encoded correctly, each being represented with double byte characters and the question marks.
Do you have any clues on the issue?
Thank you for you work, the tool is very handy and easily portable between the Office programs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.