Yes, they do.Has anyone tried adding the images directly to MSysRecources? Do they then show up in the gallery?
embedded in the form
The only way I know how to get a copy of the embedded image is by exporting the form to XML.Hello, thank you for your kindness. It was great.
I have another question?
When an image is embedded in the form, where is this image stored and accessible?
Public Function savePictInForm(frm As Access.Form)
Dim fname As String 'The name of the file to save the picture to
Dim pngImage As String 'Stores the image data as a string
Dim iFileNum As Double
fname = CurrentProject.Path & "\Temp.png"
iFileNum = FreeFile 'The next free file from the file systemc
pngImage = StrConv(frm.PictureData, vbUnicode) 'Convert the byte array to a string
MsgBox "Saved to: " & fname
'Writes the string to the file
Open fname For Binary Access Write As iFileNum
Put #iFileNum, , pngImage
Close #iFileNum
End Function
Public Function savePictInControl(ctrl As Access.Control)
Dim filename As String 'The name of the file to save the picture to
Dim strImage As String 'Stores the image data as a string
Dim iFileNum As Double
Dim realName As String
realName = ctrl.Picture
filename = CurrentProject.Path & "\" & realName
iFileNum = FreeFile 'The next free file from the file systemc
strImage = StrConv(ctrl.PictureData, vbUnicode) 'Convert the byte array to a string
Debug.Print pngImage
MsgBox "Saved to: " & filename
'Writes the string to the file
Open filename For Binary Access Write As iFileNum
Put #iFileNum, , strImage
Close #iFileNum
End Function
That may be true but I thought the point of the gallery was to make the storage of embedded images more efficient. So, if you have the same image used on several forms, is it stored ONCE in MSysResources or is it actually embedded with the form and so stored multiple times.?embedded
I have tried this....The record gets saved into MSysResources but is doesn't get and Extension and when double clicking the attachment field the file is not recognized.You can also change the embedded image (in the form) from embedded to shared, then it will be stored in MSysResources.
Option Compare Database
Option Explicit
Public Sub subExtractImageFromMsys()
Dim db As DAO.Database
Dim rs_p As DAO.Recordset2
Dim rs_c As DAO.Recordset2
Dim sPath As String
Dim sFile As String
sPath = CurrentProject.Path & "\Images\"
Set db = CurrentDb
Set rs_p = db.OpenRecordset("select * from MsysResources where [type]='img';", dbOpenDynaset)
With rs_p
If Not (.BOF And .EOF) Then
.MoveFirst
subForceMKDir sPath
Do Until .EOF
Set rs_c = .Fields("Data").Value
sFile = sPath & .Fields("Name") & "." & .Fields("Extension")
If Len(Dir$(sFile)) <> 0 Then
Kill sFile
End If
rs_c.Fields("FileData").SaveToFile sFile
Set rs_c = Nothing
.MoveNext
Loop
MsgBox "Done extracting Images to " & sPath
End If
.Close
End With
Set rs_p = Nothing
Set db = Nothing
End Sub
Public Sub subForceMKDir(ByVal sPath As String)
Dim var As Variant, v As Variant
Dim sPth As String
var = Split(sPath, "\")
On Error Resume Next
For Each v In var
sPth = sPth & v
VBA.MkDir sPth
sPth = sPth & "\"
Next v
End Sub