SignatureSet 对象 (Office)

与附加到文档的数字签名对应的 Signature 对象的集合。

备注

使用 Document 对象的 Signatures 属性可返回 SignatureSet 集合,例如:

Set sigs = ActiveDocument.Signatures

可以使用 Add 方法将 Signature 对象添加到 SignatureSet 集合,并且可以使用 Item 方法返回现有成员。

AddSignatureLine 方法也可向该集合中添加一个 Signature 对象。 另请参见 Subset 属性,它可充当一个筛选器,用于决定该集合中是否出现某些 Signature 对象。

要从 SignatureSet 集合中删除一个 Signature 对象,请使用 Signature 对象的 Delete 方法。

示例

下面的示例提示用户选择要用于签署 Microsoft Word 中活动文档的数字签名。 要使用此示例,请在 Word 中打开一个文档,并向此函数传递与“数字证书”对话框中数字证书的“颁发者”“颁发给”字段相匹配的证书颁发者名称和证书签署者名称。 此示例将进行测试,以确保在将新签名提交到磁盘之前用户选择的数字签名满足特定条件,例如没有过期。

Function AddSignature(ByVal strIssuer As String, _ 
 strSigner As String) As Boolean 
 
 Dim sig As Signature 
 
 'Display the dialog box that lets the 
 'user select a digital signature. 
 'If the user selects a signature, then 
 'it is added to the Signatures 
 'collection. If the user doesn't, then 
 'an error is returned. 
 Set sig = ActiveDocument.Signatures.Add 
 
 'Test several properties before committing the Signature object to disk. 
 If sig.Issuer = strIssuer And _ 
 sig.Signer = strSigner And _ 
 sig.IsCertificateExpired = False And _ 
 sig.IsCertificateRevoked = False And _ 
 sig.IsValid = True Then 
 
 MsgBox "Signed" 
 AddSignature = True 
 'Otherwise, remove the Signature object from the SignatureSet collection. 
 Else 
 sig.Delete 
 MsgBox "Not signed" 
 AddSignature = False 
 End If 
 
End Function

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。