Results 1 to 11 of 11

Thread: 462 and others errors with Word

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2005
    Posts
    48

    462 and others errors with Word

    Hi ,i have got 462 error with word creating objects , this is my code:

    AddDigSig--> Put in a word document a sign
    DigSigValid --> Try to verifiy the document file

    Errors:

    AddDigSig : It's really strange ,the firts time run's ok but the second ,say 462 error and "Can not complete this actions, becasue the other aplicactions is byst, try change to activate the busy aplication and try to fix it" ,sorry for my inglish.
    And the most strange is it the wordapp.Visible = True ,have to be in true ,it's false direct say "Can not complete...."

    DigSigValid: Always say de msgbox ,telling if its signed or not ,and after the 462 error.

    I thinks that a typical createdobjected error ,i tryed to read old post that write about it , but i can fix it.

    All help will be apreciated, and thanks to everybody.

    -------------------------------

    VB Code:
    1. Public Sub AddDigSig()
    2.  'Declare the object and data type that will be used.
    3. Dim bAddSig As Boolean
    4. Dim sig As Signature
    5. Dim wordapp As Word.Application
    6.  
    7.    
    8.    'When there is an error, go to Error_Handler for error handling.
    9.    On Error GoTo Error_Handler
    10.      
    11.     Set wordapp = CreateObject("Word.Application")
    12.     wordapp.Documents.Open ("c:\word\hola.doc")
    13.     wordapp.Visible = True
    14.    
    15.     Set sig = ActiveDocument.Signatures.Add
    16.    
    17.    
    18.    'Check the validity of the digital certificate used for signing.
    19.    'If it hasn't expired AND not revoked, then set bAddSig to True.
    20.     If sig.IsCertificateExpired = False And _
    21.        sig.IsCertificateRevoked = False Then
    22.            
    23.       bAddSig = True
    24.     Else
    25.       'If it isn't valid, delete the signature on the document.
    26.        sig.Delete
    27.        bAddSig = False
    28.     End If
    29.    
    30.    'Commit the signature. Until the Commit method is executed,
    31.    'none of the changes to the SignatureSet collection are saved.
    32.    ActiveDocument.Signatures.Commit
    33.    
    34.    'Clean up by destroying the sig object now that it isn't needed anymore.
    35.    Set sig = Nothing
    36.    'wordApp.Documents.Close ("c:\word\hola.doc")
    37.    wordapp.Quit
    38.    Set wordapp = Nothing
    39.    
    40.    
    41. Exit Sub
    42.  
    43. Error_Handler:
    44.      MsgBox "Document signing action has been cancelled."
    45.      Set sig = Nothing
    46.      wordapp.Quit
    47.      Set wordapp = Nothing
    48. End Sub
    49.  
    50.  
    51. Public Sub DigSigValid()
    52.  
    53.    'Declare the objects and data type that will be used.
    54.    Dim sSigValid As String
    55.    Dim objSignature As Signature
    56.    Dim wordapp As Word.Application
    57.    
    58.  
    59.    'When there is an error, go to Error_Handler for error handling.
    60.    On Error GoTo Error_Handler
    61.  
    62.    'Check all of the signatures
    63.    sSigValid = ""
    64.      
    65.    Set wordapp = CreateObject("Word.Application")
    66.    wordapp.Documents.Open ("c:\word\hola.doc")
    67.    wordapp.Visible = True
    68.  
    69.    For Each objSignature In ActiveDocument.Signatures
    70.        sSigValid = sSigValid + "Is Signature from: " + objSignature.Signer _
    71.        + " Valid?: " + Str$(objSignature.IsValid) + vbCrLf
    72.    Next objSignature
    73.  
    74.    MsgBox (sSigValid)
    75.    Set objSignature = Nothing
    76.    wordapp.Quit
    77.    Set wordapp = Nothing
    78. Exit Sub
    79.  
    80. Error_Handler:
    81.    MsgBox "An error has occurred while trying to validate the digital signature. Please try running the DigSigValid macro again."
    82.    Set objSignature = Nothing
    83.    wordapp.Quit
    84.    Set wordapp = Nothing
    85. End Sub
    Last edited by si_the_geek; Nov 7th, 2005 at 02:56 PM. Reason: added VBCode tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width