[Solved] Progress bar in my macro

Creating a macro - Writing a Script - Using the API

[Solved] Progress bar in my macro

Postby Ponny » Thu Jan 19, 2017 7:35 pm

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
Last edited by Hagar Delest on Fri Jan 20, 2017 9:14 am, edited 1 time in total.
Reason: tagged [Solved].
MS Windows 10: OpenOffice 4.1.7
User avatar
Ponny
 
Posts: 120
Joined: Sun Jun 21, 2009 7:34 pm
Location: Mystical Kingdom of Krakovo

Re: Progress bar in my macro

Postby FJCC » Thu Jan 19, 2017 7:57 pm

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   Expand viewCollapse view
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
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7523
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Progress bar in my macro

Postby musikai » Thu Jan 19, 2017 8:36 pm

The code above drives the ProgressBar at the Bottom of document window.

From here (https://wiki.openoffice.org/wiki/Documentation/DevGuide/Basic/Progress_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   Expand viewCollapse view
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
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/libreofficesongbookarchitect.html
musikai
Volunteer
 
Posts: 278
Joined: Wed Nov 11, 2015 12:19 am

Re: Progress bar in my macro

Postby Ponny » Thu Jan 19, 2017 9:31 pm

It works, thankyou.
I searched in OOo help, and found nothing.
Thankyou again and good night.


Ponny
MS Windows 10: OpenOffice 4.1.7
User avatar
Ponny
 
Posts: 120
Joined: Sun Jun 21, 2009 7:34 pm
Location: Mystical Kingdom of Krakovo

Re: Progress bar in my macro

Postby Villeroy » Thu Jan 19, 2017 10:18 pm

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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 27876
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Progress bar in my macro

Postby RoryOF » Thu Jan 19, 2017 10:36 pm

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.
Apache OpenOffice 4.1.7 on Xubuntu 18.04.4 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 30617
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 2 guests