You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用InkPicture为Excel添加签名时触发438错误如何解决

报错原因

用户窗体上的ActiveX控件默认返回的是VBA封装的表层控件对象,不是MSINKAUTLib.InkPicture对应的原生接口对象,直接赋值时类型不匹配,因此触发对象不支持属性或方法的438错误。

解决方法

仅需要修改报错行的赋值逻辑,通过.Object属性获取原生InkPicture对象即可:

  • 将原代码中的Set objInk = Me.SignPicture修改为:
Set objInk = Me.SignPicture.Object

如果修改后仍有异常,可以额外检查VBA编辑器的「工具-引用」设置,确认已勾选Microsoft Ink Controls类库。

修改后的完整代码如下:

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.Object

'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

内容的提问来源于stack exchange,提问作者Concúbháir O'Nuamain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 11:06:03