【问题标题】:How do I save an inkPicture as an image using VBA for Excel 2013?如何使用 VBA for Excel 2013 将 inkPicture 保存为图像?
【发布时间】:2015-01-17 05:57:47
【问题描述】:

我正在创建一个需要捕获客户和员工签名的 Excel 2013 电子表格。我能够将 inkPicture 控件添加到 VBA 表单中,并且签名操作正在运行。我想让这两个人在表格上的 inkPictures 上签名后,他们的签名会保存为工作表上的图像。之后,代码将锁定工作表。

我正在工作站上开发它,但它将用于平板电脑。据我所知,inkPicture 控件不会显示在操作系统的非移动版本(或者它可能是 Excel?)的工作表上。我的雇主还没有给我平板电脑,所以我不知道平板电脑上发生了什么。但这就是为什么我希望将签名保存在工作表上的图像控件中。

我认为我不能使用商业签名包,据我所见,它们会锁定整个文件,而不仅仅是单个工作表。

我在网上看过不少文章,但它们似乎都使用 VB.NET 或 C#.NET,我无法将这些示例翻译成 VBA。同样,问题是:如何将 inkPicture 笔画保存到工作表上的图像上?谢谢!

抱歉,这里没有可显示的代码,我在办公室做了一些工作,但我是在家发布的(是的,在我的休息日)。

【问题讨论】:

    标签: excel vba controls


    【解决方案1】:

    好的,我知道了如何将签名保存为 .gif 文件。但我无法将图像文件加载回工作表上的图像控件。您在下面看到的是我如何将图像本身放到工作表上。但后来,我决定将图像添加到按钮控件中。来了……

    Private Sub cmdContinue_Click()
        Dim imgBytes() As Byte
        Dim strFileName As String
        Dim newImg
        '
        ' The real piece I was missing!
        '
        imgBytes = inkClient.Ink.Save(IPF_GIF)
        '
        ' Now save the byte array to a file
        '
        strFileName = ActiveWorkbook.Path & "\test.gif"
        Open strFileName For Binary Access Write As #1
        Put #1, 1, imgBytes
        Close #1
        '
        ' Bring the image back onto the sheet, then adjust it as needed
        '
        ActiveSheet.Unprotect Password:=strSheetPassword
        Set newImg = ActiveSheet.Pictures.Insert(strFileName)
        With newImg
            .Top = 100
            .Left = 1000
        End With
        ActiveSheet.Protect Password:=strSheetPassword
        '
        ' Code to remove the saved file goes here
        '
        '   ...
        '
        Hide     ' Hiding the form
    End Sub
    

    【讨论】:

      【解决方案2】:

      感谢您的发帖!我刚买了一个 Surface,想了解更多关于上墨的知识。

      我认为完成您想要做的事情的更简单方法是:

      ActiveSheet.Unprotect Password:=strSheetPassword
      inkClient.Ink.ClipboardCopy
      ActiveSheet.paste
         Set newImg = Selection
         With newImg
            .Top = 100
            .Left = 1000
         End With
          ActiveSheet.Protect Password:=strSheetPassword
      

      【讨论】:

        猜你喜欢
        • 2020-07-07
        • 2023-03-23
        • 2014-01-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多