border

Miembros:
Mensajes:
Temas:
Online:

Ultimo Miembro:

 
 

  #1 (permalink)  
Antiguo 28-10-2005, 10:14:12
Buena Participación en el Foro
 
Registrado: sep 2004
Posts: 84
bats Valoración +2
Predeterminado firma digital, uf....casi......

Mirando y mirando ,casi lo consigo ,pero tengo un error, y es que solo puedo comprovar la firma una vez, a la segunda me da un error.

A ver si alguien puede echarme una mano con esto:

Nota: Poner en referencia Ms Word ,y creo que tambien la de Office

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

Private Sub Command1_Click()
DigSigValid ' Comprovar si tiene la firma correcta
End Sub


Private Sub Command3_Click()
AddDigSig ' Poner una firma en un documento
End Sub



Public Sub AddDigSig()
'Declare the object and data type that will be used.
Dim bAddSig As Boolean
Dim sig As Signature
Debug.Print file_name
Dim m_WordServer As Word.Application


'When there is an error, go to Error_Handler for error handling.
On Error GoTo Error_Handler

'Initialize the Signature object and add a signature to the document.
'If the document hasn't been saved:
'#1 user will be asked to save it first before signing.
'#2 After it's saved user will be asked to select the digital certificate for signing.
'If the document has already been saved, then user will only be be presented with #2.

Set wordApp = CreateObject("Word.Application")
wordApp.Documents.Open ("c:\word\hola.doc") ' Aqui el documento a firmar
wordApp.Visible = False


Set sig = ActiveDocument.Signatures.Add


'Check the validity of the digital certificate used for signing.
'If it hasn't expired AND not revoked, then set bAddSig to True.
If sig.IsCertificateExpired = False And _
sig.IsCertificateRevoked = False Then

bAddSig = True
Else
'If it isn't valid, delete the signature on the document.
sig.Delete
bAddSig = False
End If

'Commit the signature. Until the Commit method is executed,
'none of the changes to the SignatureSet collection are saved.
ActiveDocument.Signatures.Commit

'Clean up by destroying the sig object now that it isn't needed anymore.
Set sig = Nothing
wordApp.Quit
Set wordApp = Nothing


Exit Sub

Error_Handler:
bAddSig = False
MsgBox "Document signing action has been cancelled."
Set sig = Nothing
wordApp.Quit
Set wordApp = Nothing
End Sub



Public Sub DigSigValid()

'Declare the objects and data type that will be used.
Dim sSigValid As String
Dim objSignature As Signature



'When there is an error, go to Error_Handler for error handling.
On Error GoTo Error_Handler

'Check all of the signatures
sSigValid = ""

Set wordApp = CreateObject("Word.Application")
wordApp.Documents.Open ("c:\word\hola.doc") ' Aqui el documento a comprovar
wordApp.Visible = False

For Each objSignature In ActiveDocument.Signatures
sSigValid = sSigValid + "Is Signature from: " + objSignature.Signer _
+ " Valid?: " + Str$(objSignature.IsValid) + vbCrLf
Next objSignature

MsgBox (sSigValid)

'Create a new document.
' Set docNew = Documents.Add

'Print on the newly created document the value of sSigValid.
' Selection.TypeText (sSigValid)

'Clean up by destroying the docNew object now that it isn't needed anymore.
' docNew.Close
' Set docNew = Nothing

Set objSignature = Nothing
' wordApp.Close
wordApp.Quit
Set wordApp = Nothing
Exit Sub

Error_Handler:
MsgBox "An error has occurred while trying to validate the digital signature. Please try running the DigSigValid macro again."
' docNew.Close
' Set docNew = Nothing
Set objSignature = Nothing
wordApp.Quit
Set wordApp = Nothing
End Sub


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

Gracias de nuevo
Responder Con Cita
  #2 (permalink)  
Antiguo 28-10-2005, 10:15:12
Buena Participación en el Foro
 
Registrado: sep 2004
Posts: 84
bats Valoración +2
Predeterminado Perdon faltan capicom

Perdon, creo que tambien hace falta la referencia a las Capicom
Responder Con Cita
  #3 (permalink)  
Antiguo 10-11-2005, 07:24:37
Buena Participación en el Foro
 
Registrado: sep 2004
Posts: 84
bats Valoración +2
Predeterminado Al 95% ,falla Excel ,Ok en Word i PPT

Bueno ,me voy respondiendo a mi mismo ,aqui teneis casi una solucion total para este tema. Espero que alguien le pueda ayudar, y si alguiem me puede dar una solucion para los archivos excel pues mejor ,pues en este tipo de archivo no se como puedo poner la firma digital.

Gracias..

------------------
AddSign ,le pasamos el documento a firmar, y un entero diciendo el tipo de fichero ,1 Word ,2 Excel (el que me falla) ,3 PPT

Referencias, Ms Office 11.0 Object Library ,lo mismo en Word ,Excel y Power Point, Tambien las capicom y no se si me olvido de alguna otra.

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


Public Sub AddDigSig(docu As String, tipus As Integer)
'Declare the object and data type that will be used.
Dim bAddSig As Boolean

'*** note that this should be defined fully, possibly as Word.Signature
Dim sig As Office.Signature
Dim wordapp As Word.Application
Dim worddoc As Word.Document
Dim pptapp As PowerPoint.Application
Dim pptdoc As PowerPoint.Presentation
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet


'When there is an error, go to Error_Handler for error handling.

On Error GoTo Error_Handler

Select Case tipus '"select case" is like if, but you can check multiple values
Case 1
Set wordapp = CreateObject("Word.Application")
Set worddoc = wordapp.Documents.Open(docu)
wordapp.Visible = True
Set sig = worddoc.Signatures.Add
Case 2
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open(docu)
xlApp.Visible = True
Set sig = ActiveDocument.Signatures.Add
'not sure if this is right:
' Set sig = xlBook.Signatures.Add

'may need to be this instead:
'Set xlSheet = xlBook.Worksheets(1)
'Set sig = xlSheet.Signatures.Add
Case 3
Set pptapp = CreateObject("PowerPoint.Application")
pptapp.WindowState = ppWindowMinimized
pptapp.Visible = True
Set pptdoc = pptapp.Presentations.Open(docu)
pptapp.Visible = True
Set sig = pptdoc.Signatures.Add
End Select



'Check the validity of the digital certificate used for signing.
'If it hasn't expired AND not revoked, then set bAddSig to True.
If sig.IsCertificateExpired = False And _
sig.IsCertificateRevoked = False Then

bAddSig = True
Else
'If it isn't valid, delete the signature on the document.
sig.Delete
bAddSig = False
End If

'Commit the signature. Until the Commit method is executed,
'none of the changes to the SignatureSet collection are saved.

If tipus = 1 Then
worddoc.Signatures.Commit
Set sig = Nothing
worddoc.Close SaveChanges:=True
Set worddoc = Nothing
wordapp.Quit
Set wordapp = Nothing

Else
If tipus = 3 Then
pptdoc.Signatures.Commit
Set sig = Nothing
pptdoc.Close
' pptdoc.Close SaveChanges:=True
Set pptdoc = Nothing
pptapp.Quit
Set pptapp = Nothing
End If
End If

'Clean up by destroying the sig object now that it isn't needed anymore.


'*** save and close the document

Exit Sub

Error_Handler:
MsgBox "Document signing action has been cancelled."
MsgBox "Se ha producido el siguiente error:" & vbCrLf & _
Err.Number & ", " & Err.Description

Set sig = Nothing
'*** close (but dont save) the document
If tipus = 1 Then
worddoc.Close SaveChanges:=False
wordapp.Quit
Set wordapp = Nothing
Else
If tipus = 3 Then
pptdoc.Close
pptapp.Quit
Set pptapp = Nothing
End If
End If
End Sub
Responder Con Cita
  #4 (permalink)  
Antiguo 02-01-2007, 09:15:32
Un Nuevo Amigo
 
Registrado: mar 2005
Posts: 8
kontor Valoración +2
Predeterminado

bats,

Hola bats, en sept de 2004 escribias en el foro para pedir ayuda acerca de la firma digital. Te daba problema al insertarla en documentos excel, que son los que precisamente utilizo yo.
Finalmente, llegaste a alguna solución? me encuentro con el mismo problema y me urge bastante.
te agradecería cualquier ayuda.
Un saludo.
Responder Con Cita
Respuesta


Herramientas
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Trackbacks are habilitado
Pingbacks are habilitado
Refbacks are habilitado


Temas Similares
Tema Autor Foro Respuestas Último Mensaje
Firma digital en PDF sueco8 ASP.NET 0 22-02-2008 12:48:40
Firma digital Marauder Crystal Reports 1 15-02-2007 20:30:33
Firma digital bats Visual Basic 6.00 3 19-10-2005 07:00:40
firma digital pablogc Visual Basic 6.00 2 23-08-2005 09:19:35
CAPICOM (cifrado y firma digital) jsuarezs Visual Basic 6.00 4 11-02-1970 10:52:23


La franja horaria es GMT. Ahora son las 23:54:07.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
A vBSkinworks Design

Alojado en el servicio Premium de Masquewebs | Diseño mejorado por MasqueWebs

right