「Google Charts API」を利用して、URL等を一括でQRコードにするプログラムを作成します。
商品パッケージやパンフレットなどへの添付にご活用ください。

CreateQrcode.zip
1 file(s) 17.70 KB
このエクセルファイルの作り方
①マクロを使えるようにする
「マクロを使えるようにする」を参照
②URL、QRコードの表を作成
③ボタン配置時の以下の画面で「マクロ名」を「CreateQrcode」として「新規作成」を押す
④Microsoft Visual Basic for Applications」にて以下のコードを記載
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | Sub CreateQrcode() '開始行 Dim firstRow As Long : firstRow = 3 '最終行の取得 Dim lastRow As Long : lastRow = Cells(Rows.Count, 1). End (xlUp).Row 'firstRow~lastRowまで繰り返し(途中エラーが出た場合も止めずに最後まで処理) On Error Resume Next For i = firstRow To lastRow 'QRコード表示セルの高さなどを調整 With Cells(i, "B" ) .RowHeight = 65 .VerticalAlignment = xlTop '上詰め End With 'GoogleAPIでQRコードを作成 Set qr = ActiveSheet.Pictures _ .Insert( "http://chart.apis.google.com/chart?cht=qr&chs=80x80&chl=" _ + Cells(i, "A" ).Value) 'QRコードの表示位置を指定 With qr .Top = Cells(i, "B" ).Top + 2 .Left = Cells(i, "B" ).Left + 2 End With Next i On Error GoTo 0 End Sub |