Verifying a EXCEL VBA project/workbook has been signed

I’m new to certificates and signing and wanted a way to determine if my workbooks were actually signed, including after I had made changes to the workbook VBA code. After some web research I found a test and have incorporated it into the following code:


Sub TestCert()

    Dim FName  As String

    ' Get target file name

    targetwb = Application.GetOpenFilename(FileFilter:="Excel XLSM Files (*.xlsm), *.xlsm", _
                                           Title:="Select the Linehaul Settlement Helper Workbook to be updated.")
    If targetwb = False Then
        MsgBox "No target workbook selected. Update cancelled.", , "Linehaul Settlement Helper"
        Exit Sub
    End If
    If VarType(Filename) = 8 Then
        targetwb = Filename
    End If

    Application.EnableEvents = False
    Workbooks.Open Filename:=targetwb
    Application.EnableEvents = True
    State = ActiveWorkbook.VBASigned
    ActiveWorkbook.Close
    If Not State Then
        MsgBox "Warning! This document has not been digitally signed." & vbNewLine & vbNewLine & "File: " & targetwb, _
               vbCritical, "Digital Signature Warning"
    Else: MsgBox "Success! The workbook has been digitally signed." & vbNewLine & vbNewLine & "File: " & targetwb
    End If

End Sub

I created a workbook with one worksheet that has a button that invokes this code. This way I can open that workbook, click the button, and test any workbook’s status.

Hope this helps others - if there is a better way please advise.