我想在我公司的一些表格上添加一个手写的数字签名。
其目标是,选择一个文档,添加一个签名(通过使用绘图垫,这可以用Excel的Ink工具完成),并将文件存储在服务器中作为PDF格式。这样就省去了打印的必要,然后扫描表单才能获得签名。
我使用Excel作为文件操作和搜索的主界面。我还没有找到任何通过VBA使用Excel工具的引用/库。
如何在VBA中启动Ink Tools对象?我需要使用不同的软件才能得到签名吗?
发布于 2016-05-11 14:25:28
你要找的是InkEdit控件吗?
这是您可以在工具->引用中找到的标准库之一。

发布于 2016-05-12 09:59:59
更新:
在@Macro为我指明了正确的方向之后,我发现了一些有助于eSignature启动和运行的材料。
我在MSDN 数字墨水签名.概念和技术和InkPicture类上找到了一些材料,它们通过PictureBox/Userform在VB.net和C#上讨论Ink集合,再加上在另一个堆栈过流响应中的InkEdit控件,在这个堆栈过流响应中,我意识到VBAs工具箱有一个InkPicture控件附加控件,可以用来通过用户表单收集手写的eSignature。
请一步一步地找到下面的内容:
在VBAs工具箱中,工具>附加控件下的附加控件中有一个InkPicture控件,它允许您创建一个签名用户表单。

一旦添加,InkPicture可以用作工具箱上的任何其他控件。

然后是初始化签名请求的UserForm的情况。我用的是画板,但其他硬件也能用。

并根据需要存储或使用生成的映像,在我的示例中,在服务器中保存一个临时版本,然后调整大小并添加到Word文档中。
编辑:
在这里中回答了一个类似的问题,即如何使用Userform InkPicture将图像签名输入到工作表/特定单元格中,我想我应该为感兴趣的人编辑这个答案。
下面的代码将允许您打开userform,以便用户可以对墨迹字段进行签名,温和地保存图像,将InkPicture添加到工作表中,并关闭临时映像。
设置您的UserForm (我的设置是这样的,有几个额外的选项),UserForm被命名为Signature_pad,您需要的基本选项是Private Sub Use_Click()。

这是Userform中的代码:
Private Sub Use_Click()
'dim object type and byte array to save from binary
Dim objInk As MSINKAUTLib.InkPicture
Dim bytArr() As Byte
Dim File1 As String
'get temp file path as $user\Temp\[file name]
FilePath = Environ$("temp") & "\" & "Signature.png"
' set objInk as image/strokes of InkPicture control form object
Set objInk = Me.SignPicture
'if object is not empty
If objInk.Ink.Strokes.Count > 0 Then
'get bytes from object save
bytArr = objInk.Ink.Save(2)
'create file for output
Open FilePath For Binary As #1
'output/write bytArr into #1/created (empty)file
Put #1, , bytArr
Close #1
End If
'set public File as file path to be used later on main sub
Signature.File = FilePath
Unload Me
End Sub
Private Sub Cancel_Click()
End
End Sub
Private Sub ClearPad_Click()
'delete strokes/lines of signature
Me.SignPicture.Ink.DeleteStrokes
'refresh form
Me.Repaint
End Sub下面是调用userform并处理签名的Main sub (模块名为Signature),您可以使用button调用这个Sub或形成另一个Sub。
'public temp file path
Public File
Sub collect_signature()
'Dim and call userform
Dim myUserForm As Signature_pad
Set myUserForm = New Signature_pad
myUserForm.Show
Set myUserForm = Nothing
'insert image/signature from temp file into application active sheet
Set SignatureImage = Application.ActiveSheet.Shapes.AddPicture(File, False, True, 1, 1, 1, 1)
'scale image/signature
SignatureImage.ScaleHeight 1, True
SignatureImage.ScaleWidth 1, True
'image/signature position
SignatureImage.Top = Range("A1").Top
SignatureImage.Left = Range("A1").Left
'delete temp file
Kill File
End Sub确保重命名Userform Name和Buttons Name或代码以匹配您buttons的名称。
https://stackoverflow.com/questions/37164849
复制相似问题