LoginSignup
0
1

More than 3 years have passed since last update.

URL→QR→PDF for VBScript

Posted at

これは何かというと

URL文字列をQRコードにしてPDFで保存するVBScriptです。
以前作った以下の記事の焼き直しです。
(必要な環境も前回に準じます。Microsoft Office (Excel + Access) 2016 以降、のはず。)

QRコードにしてクリップボードに格納するExcelマクロ

コード

QRPDF.vbs

QRPDF "Qiita", "https://qiita.com/", "Qiita_QR"

'URL文字列をQRコードにしてPDFで保存する関数
Function QRPDF(strTitle, strURL, strFileName)
    Dim app, wb, ws
    Dim wTitle, wQR, wURL

    Set app = CreateObject("Excel.Application")
    Set wb = app.Workbooks.Add
    Set ws = wb.Worksheets.Add

    With ws
        Set wTitle = .Range("A1")
        Set wQR = .Range("A2")
        Set wURL = .Range("A3")
    End With

    With ws.OLEObjects.Add("BARCODE.BarCodeCtrl.1")
        .Object.Style = 110
        .Top = wQR.Top
        .LinkedCell = wURL.Address
        .Width = .Height
        wQR.RowHeight = .Height
        wTitle.Value = strTitle
        wURL.Value = strURL
        wURL.EntireColumn.ColumnWidth = 30
        wURL.ShrinkToFit = True
    End With

    With ws.PageSetup
        .PrintArea = ws.UsedRange.Address
        .Orientation = 2 'xlLandscape
        .Zoom = 300
    End With
    ws.ExportAsFixedFormat 0, strFileName   '0: xlTypePDF

    wb.Close False
    app.Quit
End Function

結果イメージ

QR.PNG

今後の展開

以下の記事の処理と組み合わせて、Web会議のURLをQRコード化するVBScriptを作る予定です。

Outlookから直近の予定一覧を取得してメール(VBScript/Excelマクロ)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1