Better solution to vba sendkeys method for adding signature lines to word or excel

bradyboyy88

Well-known Member
Joined
Feb 25, 2015
Messages
562
Hi,

I need to add a signature block and I have the code below. However it brings up a dialog box where you have to press enter to make it go away and it will add the signature and details. I need to bypass the dialog box which it doesnt seem possible so instead I was thinking of using sendkeys. However, this message seems so unreliable that maybe there is a better solution out there?

thanks

Code:
Sub Macro1()
    Dim mysignature1 As Signature
    Set mysignature1 = ActiveDocument.Signatures.AddSignatureLine("{00000000-0000-0000-0000-000000000000}")
    mysignature1.Setup.SuggestedSigner = "Name"
    mysignature1.Setup.SuggestedSignerLine2 = "Project Manager"
    mysignature1.Setup.SuggestedSignerEmail = "email@domain.com"
    
End Sub
 
Last edited:

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
In Excel, you can use DisplayAlerts to suppress that dialog.

Code:
Sub Macro1()
    Dim mysignature1 As Signature
    [B][COLOR="#0000CD"]Application.DisplayAlerts = False[/COLOR][/B]
    Set mysignature1 = ActiveWorkbook.Signatures.AddSignatureLine("{00000000-0000-0000-0000-000000000000}")
    mysignature1.Setup.SuggestedSigner = "Name"
    mysignature1.Setup.SuggestedSignerLine2 = "Project Manager"
    mysignature1.Setup.SuggestedSignerEmail = "email@domain.com"
    [B][COLOR="#0000CD"]Application.DisplayAlerts = True[/COLOR][/B]
    
End Sub
 
Upvote 0
Yea the Application.DisplayAlerts does not seem to suppress this in microsoft word. Although I am doing this all from excel vba, I am creating a microsoft word object and running this code (well modified to run from excel but you get the point).
 
Upvote 0
For a Word Document, since you are executing this from Excel, one workaround would be to create the signature in Excel (on a temporarily added sheet), then cut and paste into the Word doc.

When I tested this manually, it came into Word as a working signature and not just a picture. I presume that approach could be automated with VBA to avoid the dialog in Word.
 
Upvote 0
For a Word Document, since you are executing this from Excel, one workaround would be to create the signature in Excel (on a temporarily added sheet), then cut and paste into the Word doc.

When I tested this manually, it came into Word as a working signature and not just a picture. I presume that approach could be automated with VBA to avoid the dialog in Word.

Let me ask you this, when you created your digital signature did you sign it with a certificate? If so, when you copied and pasted it, did it still have the certificate attached?

I just tested it manually and when i create the digital signature and then sign in excel it creates the signature. But when I hit copy and paste it does not seem to carry over the signature but just the signature line into word. I also just copied over the signature line into word and I cannot seem to right click and sign it, instead it seems to treat it like a image. I am using office 2013.
 
Last edited:
Upvote 0
Actually clicking off it and then waiting a few seconds and clicking back on lets me sign it!!

The next challenge is trying to suppress the signing dialog box, so far I have this code which adds the signing image. Is there a way using vba to select a certain certificate to use?

Code:
    mysignature1.Sign ("C:\Users\TEST\Pictures\Screenshots\Screenshot (1).png")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,301
Members
449,078
Latest member
nonnakkong

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top