The custom ribbon uses the tblBinary to store images, but how do you get them out, if you want to use the nice images again for something else like a webpage toolbar?
How to get the images out of tblBinary
Well this code will loop the tblBinary table and save each image to the specified folder:
Sub SaveImages() 'How to get the images out of tblBinary Dim rst As Recordset Dim strOrdner As String Dim strSelectFile As String Set rst = CurrentDb.OpenRecordset("SELECT FileName FROM tblBinary") strOrdner = "C:\a\_toolbar images\" Do Until rst.EOF strSelectFile = rst.Fields(0) If strSelectFile <> "" Then If strOrdner <> "" Then If RestoreBinFile(strSelectFile, strOrdner) = True Then MsgBox "The file """ & strSelectFile & """ was saved in """ & strOrdner & """ .", vbInformation, "Save File" End If End If End If rst.MoveNext Loop rst.Close Set rst = Nothing End Sub 'This code actually came from a database at this link: https://www.accessribbon.de/en/?Downloads:25 Function RestoreBinFile(sFileName, sPath As String, Optional Overwrite As Boolean = True) As Boolean Dim F As Integer Dim LSize As Long Dim arrBin() As Byte Dim rs As DAO.Recordset On Error GoTo Errr If Not tblBinExists Then Err.Raise vbObjectError + 3, "mdlBinary", _ "Binärtabelle 'tblBinary' existiert nicht in dieser Datenbank!" If Right(sPath, 1) <> "\" Then sPath = sPath & "\" If Dir(sPath, vbDirectory) = "" Then Err.Raise vbObjectError + 4, "mdlBinary", _ "Verzeichnis " & sPath & " existiert nicht!" If (Dir(sPath & sFileName) <> "") And Not Overwrite Then Err.Raise vbObjectError + 4, _ "mdlBinary", "Datei " & sFileName & " existiert bereits!" Set rs = DBEngine(0)(0).OpenRecordset("tblBinary", dbOpenDynaset) rs.FindFirst "[FileName]='" & sFileName & "'" If rs.NoMatch Then Err.Raise vbObjectError + 5, "mdlBinary", _ "Das Binär-File " & sFileName & " existiert nicht in der Tabelle 'tblBinary!'" Else LSize = rs.Fields("binary").FieldSize ReDim arrBin(LSize) arrBin = rs.Fields("binary").GetChunk(0, LSize) F = FreeFile Open sPath & sFileName For Binary As #F Put #F, , arrBin Close #F End If rs.Close RestoreBinFile = True fExit: Reset Erase arrBin Set rs = Nothing Exit Function Errr: MsgBox Err.Description Resume fExit End Function
Let me know if you have any questions.
Read this for how to get the images into tblBinary
How To Parse A Flat File In Excel VBA
In another post I demonstrated how to access a file on your computer using the MS Office Library. Here it is if you don’t know what I’m talking about. In this post, I am going to show you how to access the file and load it into your spreadsheet. I will do the same thing […]
How can I interact with other Office applications (Excel) using VBA in Access?
Need to write your Access data or query to an Excel file? Here is the how to do it: Most people are familiar with Excel and know how to use it well (enough), and when you start talking about Access, they get scared off, and don’t know what to do anymore. Well, here you are […]
How To Generate A XML File With Access VBA
XML is used to structure your data. You can send a CSV file to another person, but using XML, you can structure your data in a more elegant format, and get very specific about your fields, and what data is contained within your tags (your field names). This is different than a basic CSV file […]
Mouse Click Counter On Access Form
This post will demonstrate how you can count the number of clicks on your button in a certain time frame. It will function like a game . Here is the database form all in one: Option Compare Database Public m_dteStartTime As Date Public m_dteStopTime As Date Private Sub btnClicker_Click() Dim intValue As Integer Dim rst […]