Office VBA教程:AttachCertificate属性

如果对应于指定 Signature对象的数码证书附加到文档,则返回 True。Boolean 类型,可读写。

expression.AttachCertificate

expression   必需。该表达式返回“应用于”列表中的对象之一。

VBA示例

本示例提示用户选择 Microsoft Word 中活动文档的数字签名。要使用本示例,请在 Word 中打开文档并调用该函数。该函数将进行测试以确保用户所选择的数字签名在 12 个月内不会过期。如果将会过期,则不附加证书。


Function AddSignature() As Boolean
    On Error GoTo Error_Handler
    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
    sig.AttachCertificate = True
    'Test to make sure that the new Signature object
    'doesn't expire too soon. This expression calculates
    'the number of months until the Signature object expires.
    If DateDiff("m", sig.SignDate, sig.ExpireDate) < 12 Then
        MsgBox "This certificate will expire in less than 1 year." & vbCrLf & _
        "Please use a newer certificate."
        AddSignature = False
        sig.Delete
    Else
        AddSignature = True
    End If
    'Commit all signatures in the SignatureSet collection to the disk.
    ActiveDocument.Signatures.Commit
    Exit Function
Error_Handler:
    AddSignature = False
    MsgBox "Action cancelled."
End Function

上页:Office VBA教程:AssistWithWizards属性 下页:Office VBA教程:BalloonError属性

Office VBA教程:AttachCertificate属性

Office VBA教程:BalloonError属性 Office VBA教程:BalloonType属性
Office VBA教程:BeginGroup属性 Office VBA教程:BuiltIn属性
Office VBA教程:BuiltInFace属性 Office VBA教程:Button属性
Office VBA教程:ButtonName属性 Office VBA教程:Callback属性
Office VBA教程:Caption属性 Office VBA教程:Checkboxes属性
Office VBA教程:Checked属性 Office VBA教程:Column属性
Office VBA教程:Columns属性 Office VBA教程:CommandBar属性
Office VBA教程:CommandBars属性 Office VBA教程:CompareTo属性
Office VBA教程:Comparison属性 Office VBA教程:Condition属性
Office VBA教程:Conjunction属性 Office VBA教程:Connect属性
版权所有 © 中山市飞娥软件工作室 证书:粤ICP备09170368号