0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【VBA】Workbookにある署名の数を数えるマクロ

Posted at

目的

署名付きのExcelファイルにあるすべての署名の中から、署名済み/未署名の署名欄が何件あるかを集計する。

環境

  • Windows 10 Pro x64
  • Microsoft 365 Excel 64ビット

概要

Workbook.SignaturesのSubsetのプロパティを指定することで、どの種類の署名に対して操作をするかを決定しています。

設定値に関しては以下のURL/表をご参照ください。
https://learn.microsoft.com/ja-jp/office/vba/api/office.msosignaturesubset

名前 説明
msoSignatureSubsetAll 5 すべての非表示の署名およびすべての署名欄
msoSignatureSubsetSignatureLines 2 すべての署名欄
msoSignatureSubsetSignatureLinesSigned 3 署名済み署名欄
msoSignatureSubsetSignatureLinesUnsigned 4 未署名の署名欄
msoSignatureSubsetSignaturesAllSigs 0 すべての非表示の署名およびすべての署名済み署名欄
msoSignatureSubsetSignaturesNonVisible 1 すべての非表示の署名

コード

.vas
Option Explicit

Sub Main()
    Dim path_ As String
    Dim wb As Workbook
    Dim totalCount As Long
    Dim signedCount As Long
    
    path_ = "***.xlsx"
    Set wb = Workbooks.Open(path_, ReadOnly:=True)
    
    With wb.Signatures
        .Subset = msoSignatureSubsetAll
        totalCount = .Count
        .Subset = msoSignatureSubsetSignatureLinesSigned
        signedCount = .Count
    End With
    
    MsgBox (signedCount & "/" & totalCount & " signed.")
    
    wb.Close False
End Sub
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?