开发者

I am trying to use VBA code to save inkpicture contents, can only use vb.net or C#

I found this code that is missing the function call in the last line, any ideas on what the save to file command would be?, I'll just kludge it in.

'CODE to SAVE InkPicture to FILE
Dim objInk As MSINKAUTLib.InkPicture
Dim byt开发者_如何学编程Arr() As Byte
Dim File1 As String
File1 = "C:\" & TrainerSig & ".gif"
Set objInk = Me.InkPicture2.Object
If objInk.Ink.Strokes.Count > 0 Then
    bytArr = objInk.Ink.Save(2)
    fSaveFile bytArr, File1
End If


Here is a kludgy version of saving .InkPicture with VBA code in Access 2007 to a .isf file.

Private Sub Command283_Click()
    'CODE to SAVE InkPicture to FILE
    Dim objInk As MSINKAUTLib.InkPicture
    Dim bytArr() As Byte
    Dim File1 As String

    File1 = "C:\test.isf"

    Set objInk = Me.InkPicture2.Object

    If objInk.Ink.Strokes.Count > 0 Then
        bytArr = objInk.Ink.Save(2)
        Open File1 For Binary As #1
        Put #1, , bytArr
        Close #1
    End If
End Sub


I tried zaphod23's solution and it did not work for me. I also thought it quite strange that the solution would save in a .isf format, normally people want to save inkPicture contents to an image file (jpg, gif, etc.). It took me a while to hunt down the pieces of this code and put it together, so I'll post it here for others who might find it useful.

This takes an inkPicture object used for a signature panel in a Microsoft Access form, saves the contents as a gif image, then puts the image in an image object on the form (which is useful because the inkPicture contents will not show up when you go to print the form).

On Error Resume Next
Dim imgBytes() As Byte
Dim sFilePathAndName As String

imgBytes = Me.signaturePanel.Ink.Save(IPF_GIF)

If (UBound(imgBytes) = 0) Then
    MsgBox ("Please enter your signature")
Else
    sFilePathAndName = (Application.CurrentProject.Path & "\images\system\signatures\" & "signature")
    Open sFilePathAndName For Binary Access Write As #1
    Put #1, 1, imgBytes
    Close #1
    Me.imgSignature.Picture = sFilePathAndName
End If
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜