Reply
 
Thread Tools Display Modes
  #1   Report Post  
 
Posts: n/a
Default Word 2003 and Digital Signatures

Is it possible to automate the signing of Word 2003 docs with
Digital Signatures?


My problem with the code approach using


ActiveDocument.Signatures.Add


is that Word comes up with a prompt. Obviously this is no good
when trying to automate document creation, etc.


There doesn't appear to be any way to specify a particular
certificate, or to suppress the prompt.


I assume there must be some way to add digital signatures to
Word 2003 docs thru code, but how?


I am using VB.Net to automate Word.


Any suggestions gratefully received.

  #2   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

As far as I know, this isn't possible. If one could sign
documents through code, then a digital signature might not be
worth very much?

In any case, this is an end-user newsgroup. A better place to ask
this type of question would be one of the office.developer groups.

Is it possible to automate the signing of Word 2003 docs with
Digital Signatures?


My problem with the code approach using


ActiveDocument.Signatures.Add


is that Word comes up with a prompt. Obviously this is no good
when trying to automate document creation, etc.


There doesn't appear to be any way to specify a particular
certificate, or to suppress the prompt.


I assume there must be some way to add digital signatures to
Word 2003 docs thru code, but how?


I am using VB.Net to automate Word.


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8
2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)

  #3   Report Post  
 
Posts: n/a
Default

Don't see how signing a doc thru code is any less secure.

You still need a certificate, just using code to remove the grunt work
of signing individual docs.

For example, see signcode.exe. It's a command line tool that allows
signing code (dlls, exe, etc). This could easily be automated if one
was
so inclined.

Wonder why there is no comparable tool for signing other files, incl
..doc?

  #4   Report Post  
 
Posts: n/a
Default

Well, after several days of sweat and tears I've finally come up with
something.

It's almost the hackiest code I've ever written but it works. If anyone
comes
up with something better, please post it.

In the end I run the ActiveDocument.Signatures.Add code as normal and
then
"hit enter" from another thread, making sure to direct the keystroke to
the
correct window.


'waiting for certificate prompt to be shown
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'API declarations, etc that allow us to talk directly to our running
instance of Word
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
lParam As Int32) As Int32
Public Const WM_CHAR = &H102
Public Const VK_RETURN = &HD
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public rc As Int32


sub SignDoc()

wrdApp.Documents.Open(drContracts("DocLocation"))

'''
'
'We want to digitally sign the doc, make it read only for the client
Dim sig As Microsoft.Office.Core.Signature
Dim t As WordSignatureDelegate
t = AddressOf WordSignature
If blnFirstRun Then
t.BeginInvoke(True, Nothing, Nothing)
Else
t.BeginInvoke(False, Nothing, Nothing)
End If

Logger.Write("Attempting to add signature to : " &
drContracts("DocLocation"))
sig = wrdApp.ActiveDocument.Signatures.Add
sig.AttachCertificate = True
wrdApp.ActiveDocument.Signatures.Commit()
Logger.Write("Signature added to : " & impDealRef)

'
'''

wrdApp.ActiveDocument.Close()

End Sub

Public Delegate Sub WordSignatureDelegate(ByVal blnFirstRun As Boolean)

Public Sub WordSignature(ByVal blnFirstRun As Boolean)

Dim intHandle As Int32

Sleep(5000) 'wait for Signatures.Add to run

intHandle = FindWindow("#32770", "select certificate")
rc = PostMessage(intHandle, WM_KEYDOWN, 13, 0)
rc = PostMessage(intHandle, WM_KEYUP, 13, 0)

'on the first run, we need to hit enter twice
If blnFirstRun Then
Sleep(5000) 'wait for next dialog to show

intHandle = FindWindow("#32770", "Signing data with your private
exchange key")
rc = PostMessage(intHandle, WM_KEYDOWN, 13, 0)
rc = PostMessage(intHandle, WM_KEYUP, 13, 0)
End If
End Sub

  #5   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

If you want help to refine your code, you would do better to post in one of
the word.vba NGs. If you read even a small sampling of the posts here, you
would realize that this is an end-user NG that primarily deals with the most
basic of questions.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

wrote in message
oups.com...
Well, after several days of sweat and tears I've finally come up with
something.

It's almost the hackiest code I've ever written but it works. If anyone
comes
up with something better, please post it.

In the end I run the ActiveDocument.Signatures.Add code as normal and
then
"hit enter" from another thread, making sure to direct the keystroke to
the
correct window.


'waiting for certificate prompt to be shown
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

'API declarations, etc that allow us to talk directly to our running
instance of Word
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal
lParam As Int32) As Int32
Public Const WM_CHAR = &H102
Public Const VK_RETURN = &HD
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public rc As Int32


sub SignDoc()

wrdApp.Documents.Open(drContracts("DocLocation"))

'''
'
'We want to digitally sign the doc, make it read only for the client
Dim sig As Microsoft.Office.Core.Signature
Dim t As WordSignatureDelegate
t = AddressOf WordSignature
If blnFirstRun Then
t.BeginInvoke(True, Nothing, Nothing)
Else
t.BeginInvoke(False, Nothing, Nothing)
End If

Logger.Write("Attempting to add signature to : " &
drContracts("DocLocation"))
sig = wrdApp.ActiveDocument.Signatures.Add
sig.AttachCertificate = True
wrdApp.ActiveDocument.Signatures.Commit()
Logger.Write("Signature added to : " & impDealRef)

'
'''

wrdApp.ActiveDocument.Close()

End Sub

Public Delegate Sub WordSignatureDelegate(ByVal blnFirstRun As Boolean)

Public Sub WordSignature(ByVal blnFirstRun As Boolean)

Dim intHandle As Int32

Sleep(5000) 'wait for Signatures.Add to run

intHandle = FindWindow("#32770", "select certificate")
rc = PostMessage(intHandle, WM_KEYDOWN, 13, 0)
rc = PostMessage(intHandle, WM_KEYUP, 13, 0)

'on the first run, we need to hit enter twice
If blnFirstRun Then
Sleep(5000) 'wait for next dialog to show

intHandle = FindWindow("#32770", "Signing data with your private
exchange key")
rc = PostMessage(intHandle, WM_KEYDOWN, 13, 0)
rc = PostMessage(intHandle, WM_KEYUP, 13, 0)
End If
End Sub




  #6   Report Post  
 
Posts: n/a
Default

Just after any kind of input, even a debate on Microsoft's choice to
implement signatures in this way.

End users with extensive experience might know of or have heard of an
angle.

  #7   Report Post  
still doesn'' tell me where MS hid butto
 
Posts: n/a
Default


" wrote:

Just after any kind of input, even a debate on Microsoft's choice to
implement signatures in this way.

End users with extensive experience might know of or have heard of an
angle.


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros Disabled Zedrf Microsoft Word Help 7 July 2nd 05 06:40 AM
How do I prevent unauthorized copying of sections of Word doc? Adi Raviv Microsoft Word Help 2 June 14th 05 09:19 PM
Macro Security JD Microsoft Word Help 11 April 24th 05 03:02 PM
Ink Annotate on Windows XP word 2003 K Microsoft Word Help 1 February 10th 05 12:55 AM
Word 2003 User's Guide Terry Drewes New Users 6 January 17th 05 02:37 AM


All times are GMT +1. The time now is 05:00 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"