NW27
08-25-2011, 11:05 PM
Hi All,
Two weeks ago I started to use Access for the first time and yesterday looked at VB. Mind you, I have extensive experience in Pascal, assembler, some C and QBasic/GWBasic in the DOS days.
I'm using Access 2010 and the attachment type in a table. I can generate a form and load an image from a file into this table.
What I would like to do is save the image captured onto the clipboard into the attachment field of the table.
Ie ALT+Printscreen then press a button on the Access form that puts this into the attachment field. Pressing Cntl+V on the attachment doesn't work :(
I imagine the VB code for the button press would probably be a two part process -
1. Get the image from the clipboard and save as a file ie JPG.
2. Load the JPG file into the attachment field.
I have the below code but it references a excel variable "xlBitmap" and won't compile in Access VB?
Any help for this newbie would be greatly appreciated.
Neil.
Private Sub Command21_Click()
Dim vFile As Variant, lPicType As Long, oPic As IPictureDisp
'Get the filename to save the bitmap to
'vFile = Application.GetSaveAsFilename(InitialFileName:="", filefilter:="Bmp Files (*.bmp), *.bmp")
vFile = "Chart.BMP"
If vFile <> False Then
'Get the type of bitmap
lPicType = xlBitmap
'Retrieve the picture from the clipboard...
Set oPic = PastePicture(lPicType)
'... and save it to the file
'a little check to see if there's something on the clipboard
If Not oPic Is Nothing Then
SavePicture oPic, vFile
Else
MsgBox "No picture on clipboard.", vbInformation, "Picture paste ..."
End If
Else
MsgBox "You haven't specified a filename.", vbInformation, "Picture paste ..."
End If
End Sub
Two weeks ago I started to use Access for the first time and yesterday looked at VB. Mind you, I have extensive experience in Pascal, assembler, some C and QBasic/GWBasic in the DOS days.
I'm using Access 2010 and the attachment type in a table. I can generate a form and load an image from a file into this table.
What I would like to do is save the image captured onto the clipboard into the attachment field of the table.
Ie ALT+Printscreen then press a button on the Access form that puts this into the attachment field. Pressing Cntl+V on the attachment doesn't work :(
I imagine the VB code for the button press would probably be a two part process -
1. Get the image from the clipboard and save as a file ie JPG.
2. Load the JPG file into the attachment field.
I have the below code but it references a excel variable "xlBitmap" and won't compile in Access VB?
Any help for this newbie would be greatly appreciated.
Neil.
Private Sub Command21_Click()
Dim vFile As Variant, lPicType As Long, oPic As IPictureDisp
'Get the filename to save the bitmap to
'vFile = Application.GetSaveAsFilename(InitialFileName:="", filefilter:="Bmp Files (*.bmp), *.bmp")
vFile = "Chart.BMP"
If vFile <> False Then
'Get the type of bitmap
lPicType = xlBitmap
'Retrieve the picture from the clipboard...
Set oPic = PastePicture(lPicType)
'... and save it to the file
'a little check to see if there's something on the clipboard
If Not oPic Is Nothing Then
SavePicture oPic, vFile
Else
MsgBox "No picture on clipboard.", vbInformation, "Picture paste ..."
End If
Else
MsgBox "You haven't specified a filename.", vbInformation, "Picture paste ..."
End If
End Sub