Seite 1 von 1

Dialog ListBox mit Array befüllen

Verfasst: Di, 16.05.2006 13:17
von surfhai
Hallo,

ich möchte in OO 1.1.5 ein Dialog öffnen mit den Namen der einzelnen Sheets. Allerdings bekomme ich in die ListBox mein Array nicht rein.

Code: Alles auswählen


Sub Main

		'Sheets Auslesen
		myDoc = thisComponent
		Anzahl = myDoc.Sheets.count
	
	Dim SheetNames(1) As Variant
	
		For x = 0 To Anzahl - 1
			mySheet = myDoc.Sheets(x)
			ReDim Preserve SheetNames(x) As Variant
			SheetNames(x) = mySheet.Name
			'MsgBox(SheetNames(x))
		Next x
		
		For x = 0 To UBound(SheetNames())
			If SheetNames(x) = "Einstellungen" Then
				'ArrayDelete(SheetNames(), x)
			End If
			'MsgBox(SheetNames(x))
		Next x
		
		Dim oDialog1 As Object
		Dim oListBox1 As Object
	
		oDialog1 = LoadDialog("Standard", "DlgAuswahl")
		oListBox1 = oDialog1.getControl("test")
		
		oListBox1.Items = SheetNames()
		
		'GlobalScope.BasicLibraries.LoadLibrary("Tools")
		'WriteDbgInfo(oListBox1)
		'MsgBox(oDialog1.dbg_properties)
		
		oDialog1.execute
End Sub


Jetzt komm ich einfach nichtmehr weiter.

Gruß Thorsten

Verfasst: Di, 16.05.2006 15:32
von ykcim
Hallo,

so geht es:

Code: Alles auswählen

Sub Main

      'Sheets Auslesen
      myDoc = thisComponent
      Anzahl = myDoc.Sheets.count

      Dim oDialog1 As Object
      Dim oListBox1 As Object
      Dialoglibraries.Loadlibrary("Standard")
      oDialog1= CreateUnoDialog(Dialoglibraries.Standard.DlgAuswahl)

      oListBox1 = oDialog1.getControl("test")

   
      For x = 0 To Anzahl - 1
         mySheet = myDoc.Sheets(x)
         if mySheet.Name<>"Einstellungen" then olistbox1.additem(mySheet.Name,x)
      Next x
      
      oDialog1.execute
End Sub 

mfg
Michael

Verfasst: Di, 16.05.2006 22:30
von surfhai
Hallo Michael,

danke für den Code, der funktioniert sogar und ist zudem noch optimiert :)

Gruß Thorsten