ich möchte einen existierenden Bericht aus einem existierenden Formular heraus per Button öffnen.
Anhand eines Beispielcodes auf Seite 493 aus dem Buch "Makros mit OOo 2.0" von Thomas Krumbein schaffe ich es nur, die Index-Nummer des Berichts zu ermitteln.
Sub Formular_Oeffnen
dim sFormularName as string, i as integer
dim oContext as object, oDB as Object, oVerb as object
dim arg(1) as new com.sun.star.beans.PropertyValue
dim aListe()
sFormularName = "Artikel"
REM alleFormulare und Bericht
aListe = StarDesktop.CurrentComponent.getFormDocuments().getElementNames()
REM das richtige suchen
for i = lBound(aListe) to uBound(aListe)
if aListe(i) = sFormularName then
oContext = CreateUnoService("com.sun.star.sdb.DatabaseContext")
oDB = oContext.getByName(StarDesktop.CurrentComponent.GetLocation)
oVerb = oDB.getConnection("", "")
arg(0).Name = "OpenMode"
arg(0).Value = "open"
arg(1).Name = "ActiveConnection"
arg(1).Value = oVerb
StarDesktop.CurrentComponent.getFormDocuments(). loadComponentFromURL(aListe(i), "", 0, arg())
Exit sub
end if
next
End Sub