I'm extremely new to macro programming and don't have any programming background what so ever. Still I'm trying.
Perhaps somebody can give me hint for this problem:
I have a table in a base database. In this table there's a column with Image data (so the images are stored within the database, if I understand this correctly).
Now I want to retrieve this image (mostly CD-covers) with a macro and put it in a Formfield. The idea is, that the user selects an entry from a Combo Box field and the macro fils in the rest of the form. With text-data I got this working, but I can't figure out how to do this with images.
Thanx for your time and help! (the "Product_Report" is a form and not a report, just to avoid confusion

Code: Alles auswählen
Sub EmplenirOraFormProduct_Report
dim document as object
dim dispatcher as object
DIM oDoc as object
document = ThisComponent.CurrentController.Frame
oDoc = ThisComponent
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Dim oForm as object
oForm = oDoc.drawpage.forms.getByName("Product_Report")
Dim Product as object
Product = oForm.GetByName("Combo Box Product")
DIM sProduct as String
sProduct = Product.text
'DIM ID
'ID = oForm.GetByName("fmtID")
'DIM iID as Integer
'iID = ID.text
Dim DatabaseContext As Object
Dim DataSource As Object
Dim Connection As Object
Dim InteractionHandler as Object
Dim Statement As Object
Dim ResultSet As Object
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName("R-tunes-clients")
If Not DataSource.IsPasswordRequired Then
Connection = DataSource.GetConnection("","")
Else
InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
Connection = DataSource.ConnectWithCompletion(InteractionHandler)
End If
Statement = Connection.createStatement()
''''''' DA CHEU NAVEN Interpret
ResultSetInterpret = Statement.executeQuery("SELECT DISTINCT ""Interpret"" FROM ""Products_R-tunes"" WHERE ""Product"" = '" + sProduct + "'")
If Not IsNull(ResultSetInterpret) Then
While ResultSetInterpret.next
sResultSetInterpret = ResultSetInterpret.getString(1)
Wend
End If
'Formularfeld "txtInterpret" mit neuer sResultSetInterpret füllen
oForm.getByName("txtInterpret").text = sResultSetInterpret
''''''' DA CHEU NAVEN Product image
DIM oResultSetProductImage as Object
oResultSetProductImage = Statement.executeQuery("SELECT DISTINCT ""Product image"" FROM ""Products_R-tunes"" WHERE ""Product"" = '" + sProduct + "'")
If Not IsNull(oResultSetProductImage) Then
While oResultSetProductImage.next
oStreamResultSetProductImage = oResultSetProductImage.getBinaryStream(1)
Wend
End If
If oResultSetProductImage.wasNull() Then
Print "The image was NULL"
End If
'Formularfeld "imgProduct image" mit neuer oStreamResultSetProductImage füllen
oForm.getByName("imgProduct image").addPropertyValues = oStreamResultSetProductImage
'sTgeiSei = oForm.getByName("imgProduct image").dbg_properties
'sTgeiSei = oForm.getByName("imgProduct image").dbg_methods
'print sTgeiSei
'sTgeiSei2 = oResultSetProductImage.dbg_methods
'print sTgeiSei2
'Globalscope.BasicLibraries.LoadLibrary("MRILib")
'oMRI = CreateUnoService("mytools.Mri")
'oMRI.inspect( oStreamResultSetProductImage )
END SUB