473,666 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.

Nov 21 '05 #1
1 2895
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 "FindWindow A"
(ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Private Declare Function PostMessage Lib "user32" Alias "PostMessag eA"
(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.Document s.Open(drContra cts("DocLocatio n"))

'''
'
'We want to digitally sign the doc, make it read only for the client
Dim sig As Microsoft.Offic e.Core.Signatur e
Dim t As WordSignatureDe legate
t = AddressOf WordSignature
If blnFirstRun Then
t.BeginInvoke(T rue, Nothing, Nothing)
Else
t.BeginInvoke(F alse, Nothing, Nothing)
End If

Logger.Write("A ttempting to add signature to : " &
drContracts("Do cLocation"))
sig = wrdApp.ActiveDo cument.Signatur es.Add
sig.AttachCerti ficate = True
wrdApp.ActiveDo cument.Signatur es.Commit()
Logger.Write("S ignature added to : " & impDealRef)

'
'''

wrdApp.ActiveDo cument.Close()

End Sub

Public Delegate Sub WordSignatureDe legate(ByVal blnFirstRun As Boolean)

Public Sub WordSignature(B yVal blnFirstRun As Boolean)

Dim intHandle As Int32

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

intHandle = FindWindow("#32 770", "select certificate")
rc = PostMessage(int Handle, WM_KEYDOWN, 13, 0)
rc = PostMessage(int Handle, 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("#32 770", "Signing data with your private
exchange key")
rc = PostMessage(int Handle, WM_KEYDOWN, 13, 0)
rc = PostMessage(int Handle, WM_KEYUP, 13, 0)
End If
End Sub

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7649
by: Guangxi Wu | last post by:
Hi all, Happy New Year. I am using SignedXML and an X509 certificate to digitally sign a SOAP message body and put the signature in the SOAP header for a B2B business application. Can you suggest which type of digital certificates from VeriSign is for this purpose? I checked VeriSign's web site but didn't find it obvious to decide.
5
4822
by: John Campbell | last post by:
Hi everyone I've been doing my best to understand the specifics of implimentating XML Digital Signatures, but I seem to be missing a fundamental concept. Let me start with a description of the problem I am trying to solve. In my application, people send an XML file that contains data for loans. The application then takes that data and performs various calculations returning the results in an XML file that combines both the initial data and...
0
1139
by: Bradley Ward | last post by:
I have been searching and searching online for code examples of using both ..net framework and also WSE 2.0 classes to digitally sign a SOAP document and then verify the document. I got a few hits on this site. One of them referenced an online tutorial for the WSE package that deals with digital signatures, but the link was old and no longer any good. Is there an online tutorial for using WSE to do digital signatures of XML documents,...
0
1569
by: CLarkou | last post by:
I bought a digital signature for my MSaccess application in Office 2003. I select TOOLS\Digital Signatures in Visual Basic Editor and I am not able to see my digital signature in the available ones. No BROWSE button available. Is there any directory I should copy it into ?
1
3751
by: a94ws7 | last post by:
I am trying to automate a digital signature process with Microsoft Word, I have experimented by loading the word document into word and then from there placing that document inside a picturebox so as to make it look embedded, but I am hoping I can find some resolve with using the web browser control. I can successfully load a document into the control, but how do I gain control of the word instance? Like if I want to call a save on the...
6
2168
by: simon | last post by:
I created an access database and digitally signed it. I then gave a copy of this Database to a friend. A few months later he wanted me to make some changes to it so i took an up-to-date copy from him and opened it on my computer..... but it tells me the "Visual basic project has been protected with a password". All web links tell me to open the visual basic editor and select TOOLS - DIGITAL SIGNATURES.... but the option is not there. if i...
6
1429
by: BillCo | last post by:
I've been working to date almost exclusively with a2k, but it looks like i need to move a major app to 2003. I've heard that there are various complications surrounding Digital signatures and Sandbox mode and probably a bunch of other stuff i havent even considered. I've searched newsgroups and there is tonnes of mostly junk written around version differences. Is there any good unified source of information anyone knows of about...
1
1943
by: ckpoll2 | last post by:
Hi, I have a rookie question for you. I have a database where people create a form that has to be signed. Rather than print off a hard copy, I'd like the spot for the signature to have a digital signature where it says "Digitally signed by Person X." Is this possible at all? I really don't understand digital signatures, so please forgive the the trivial nature of my problem. Thanks, Charlie
5
2008
by: troy_lee | last post by:
We have an application developed by one developer. He compiled the database into an application and digitally signed the application. He doesn't know if he used selfcert of makecert to make the key. The problem is I am creating additional forms now for the database on a different machine. Whenever we try and incorporate the forms I develop into the application, the application fails on some users' machines. We suspect it is because I am...
0
8454
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8878
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8785
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8644
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.