Page 1 of 1
[Solved] Progress bar in my macro
Posted: Thu Jan 19, 2017 7:35 pm
by Ponny
Meow
I have a little bit of problem.
I trying to put a dialog box in beginning of macro. In fact, not real dialog. Just window with progress bar, and maybe Cancel button. This window should stay open at all time of macro working. And automatic close at end of macro.
By the way. Is there any way to put progress bar for macro in status bar of OpenOffice?
Ponny
Re: Progress bar in my macro
Posted: Thu Jan 19, 2017 7:57 pm
by FJCC
Here is an example of controlling the document's status bar with a macro. I copied it from this
post in the Spanish forum. I translated the comments.
Code: Select all
Sub ControlarAplicacion4()
Dim oBarraEstado As Object
Dim co1 As Integer
'Referencia a la barra de estado del documento activo, Reference the active document's status bar
oBarraEstado = ThisComponent.getCurrentController.StatusIndicator
'Establecemos el texto inicial y el limite de la barra de progreso, Set the initial text and limit of the status bar
oBarraEstado.start( "Procesando Líneas ", 10 )
For co1 = 1 To 10
'Establecemos el valor de la barra de progreso, Set the status bar value
oBarraEstado.setValue( co1 )
'Y el texto, and the text
oBarraEstado.setText( "Procesando la línea: " & co1 )
'Esperamos un segundo, Wait one second
Wait 1000
Next
'Es importante finalizar la barra de estado para devolverle el control a la aplicación
'It is important to end the status bar process to return control to the application
oBarraEstado.end()
End Sub
Re: Progress bar in my macro
Posted: Thu Jan 19, 2017 8:36 pm
by musikai
The code above drives the ProgressBar at the Bottom of document window.
From here (
https://wiki.openoffice.org/wiki/Docume ... ogress_Bar) is the code for a dialog box.
To use it you have to create a dialog called "Dialog1" and into this insert a ProgressBarObject called "ProgressBar1". (default names)
Code: Select all
Sub ProgressBarDemo()
Dim oProgressBar as Object, oProgressBarModel As Object, oDialog as Object
Dim ProgressValue As Long
REM Dialog1 contains progress bar ProgressBar1 saved in standard library
DialogLibraries.loadLibrary("Standard")
oDialog = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
REM progress bar settings
Const ProgressValueMin = 0
Const ProgressValueMax = 40
Const ProgressStep = 4
REM set minimum and maximum progress value
oProgressBarModel = oDialog.getModel().getByName( "ProgressBar1" )
oProgressBarModel.setPropertyValue( "ProgressValueMin", ProgressValueMin)
oProgressBarModel.setPropertyValue( "ProgressValueMax", ProgressValueMax)
REM show progress bar
oDialog.setVisible( True )
REM increase progress value every second
For ProgressValue = ProgressValueMin To ProgressValueMax Step ProgressStep
oProgressBarModel.setPropertyValue( "ProgressValue", ProgressValue )
Wait 1000
Next ProgressValue
End Sub
Re: Progress bar in my macro
Posted: Thu Jan 19, 2017 9:31 pm
by Ponny
It works, thankyou.
I searched in OOo help, and found nothing.
Thankyou again and good night.
Ponny
Re: Progress bar in my macro
Posted: Thu Jan 19, 2017 10:18 pm
by Villeroy
Ponny wrote:I searched in OOo help, and found nothing.
The help includes the (almost) complete documentation for the Basic language.
It does not cover the things you can describe in that language or any other macro language.
This is not for amateurs nor "newbies". At least you should be a hobbyist with some programming background and some level of persistence.
Re: Progress bar in my macro
Posted: Thu Jan 19, 2017 10:36 pm
by RoryOF
Andrew Pitonyak's OpenOffice Macros Explained has a section on the Progress Bar at 18.3.9
His Useful Macro Information for OpenOffice.org deals with it in 10.2.9
There are a number of other references and examples easily found on the Internet.