openoffice-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathias Röllig <mroellig.n...@gmx.net>
Subject Re: macro crash problem
Date Tue, 05 May 2015 14:25:03 GMT
> Actually i have a listbox in dialog , Listbox have 2 items. when i click item,
> it opens the odt file. when i show dialog and click many times on listbox items
> program crashed.

Depends it only on the amount of clicks or also on its speed?
Do you change the window between clicks?
Do you use Option Explicit?

Please try to hold the frame in a global variable:


'for show dialog

Option Explicit
Private document as object
Private oListBox As Object
Private strDosyaIsim(1) As String
Private strDosyaYol(1) As String

Sub ShowOdtDialog()
       Dim Dlg As Object
       Dim i As Integer
       strDosyaIsim(0) = "CREDITS"
       strDosyaYol(0) = 
ConvertToURL("C:\SINERJIGROUP\YENIICRA\app\LibreOffice\CREDITS.odt")

       strDosyaIsim(1) = "LICENSE"
       strDosyaYol(1) = 
ConvertToURL("C:\SINERJIGROUP\YENIICRA\app\LibreOffice\LICENSE.odt")

       DialogLibraries.LoadLibrary("Standard")
       Dlg = CreateUnoDialog(DialogLibraries.Standard.showOdt)
       oListBox = Dlg.getControl("listOdt")

       For i=0 to Ubound(strDosyaIsim())
            oListBox.addItem(strDosyaIsim(i), i)
       next i
       document = ThisComponent.CurrentController.Frame
       Dlg.Execute()
       Dlg.dispose()
End Sub

'for select item

Sub OpenOdt()
       Dim Props() As New com.sun.star.beans.PropertyValue
 
document.loadComponentFromURL(strDosyaYol(oListBox.getSelectedItemPos()), "_self", 
0, Props())
End Sub


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@openoffice.apache.org
For additional commands, e-mail: api-help@openoffice.apache.org


Mime
View raw message