[RESUELTO] Error en tiempo de ejecución

Desarrollo de Macros y programación en UNO, usar las API, llamar programas externos...
Responder
markotxe
Mensajes: 27
Registrado: Jue May 02, 2019 9:47 am

[RESUELTO] Error en tiempo de ejecución

Mensaje por markotxe »

Hola,
Estoy intentando realizar un UserForm que cumpliría con la función de cronometro. Pero al pulsar cualquier botón del crono me aparece el mensaje de error siguiente:

"Error en tiempo de ejecución de BASIC
Se ha producido una excepción
Type:com.sun.star.container.NoSuchElementException
Message:."


La línea implicada es:
buttonStart = form.GetByName("PushButtonStart")

Código: Seleccionar todo

Sub reInit()
doc0                = ThisComponent
fa                  = CreateUnoService("com.sun.star.sheet.FunctionAccess")
sheet               = doc0.Sheets(0)
form                = sheet.DrawPage.Forms(0)
buttonStart         = form.GetByName("PushButtonStart")
buttonStart.enableVisible = True
buttonPause         = form.GetByName("PushButtonPause")
buttonPause.enableVisible = False
buttonPlay         = form.GetByName("PushButtonPlay")
buttonPlay.enableVisible = False
buttonStop          = form.GetByName("PushButtonStop")
buttonStop.enableVisible  = False
buttonReset         = form.GetByName("PushButtonReInit")
buttonReset.enableVisible = True
cellDisplay         = sheet.GetCellByPosition(3, 6)
cellDisplay.String  = ""
lastStopElapsed     = 0.0
isInit_ed           = True
End Sub
No entiendo mucho de macros y aunque haya leido temas parecidos no supe adaptar las soluciones...
Gracias
Adjuntos
TestKro.ods
(14.76 KiB) Descargado 196 veces
Última edición por markotxe el Vie May 03, 2019 10:11 pm, editado 2 veces en total.
OpenOffice 4.1.5 CALC, Window10
FJCC-ES
Mensajes: 873
Registrado: Mié Mar 25, 2009 1:19 am
Ubicación: Colorado, USA

Re: Error en tiempo de ejecucion

Mensaje por FJCC-ES »

Después de ejecutar este código

Código: Seleccionar todo

doc0                = ThisComponent
fa                  = CreateUnoService("com.sun.star.sheet.FunctionAccess")
sheet               = doc0.Sheets(0)
form                = sheet.DrawPage.Forms(0)
form.getElementNames() devuelve dos valores:
1. PushButtonNageurB
2. PushButtonNageur
form no contiene un objecto con el nombre PushButtonStart. Sí hay un botón con el nombre PushButtonStart en el diálogo.
markotxe
Mensajes: 27
Registrado: Jue May 02, 2019 9:47 am

Re: Error en tiempo de ejecucion

Mensaje por markotxe »

Hola FJCC-ES
Efectivamente, hay un botón con el nombre PushButtonStart en el diálogo.
Si entiendo bien, habría que asignar al form los objetos adecuados (PushButtonStart, PushButtonStop etc...), cierto?

Disculpar mi ignorancia pero como se hace esto?
OpenOffice 4.1.5 CALC, Window10
FJCC-ES
Mensajes: 873
Registrado: Mié Mar 25, 2009 1:19 am
Ubicación: Colorado, USA

Re: Error en tiempo de ejecucion

Mensaje por FJCC-ES »

Cambié form.getByName() a oPDialog.Model.getByName() y el código no da error.

Código: Seleccionar todo

Sub reInit()
doc0                = ThisComponent
fa                  = CreateUnoService("com.sun.star.sheet.FunctionAccess")
sheet               = doc0.Sheets(0)
form                = sheet.DrawPage.Forms(0)
'obuttonStart         = form.GetByName("PushButtonStart")
buttonStart         = oPDialog.Model.GetByName("PushButtonStart")
buttonStart.enableVisible = True
buttonPause         = oPDialog.Model.GetByName("PushButtonPause")
buttonPause.enableVisible = False
buttonPlay         = oPDialog.Model.GetByName("PushButtonPlay")
buttonPlay.enableVisible = False
buttonStop          = oPDialog.Model.GetByName("PushButtonStop")
buttonStop.enableVisible  = False
buttonReset         = oPDialog.Model.GetByName("PushButtonReset") 'Era PushButtonReInit!
buttonReset.enableVisible = True
cellDisplay         = sheet.GetCellByPosition(3, 6)
cellDisplay.String  = ""
lastStopElapsed     = 0.0
isInit_ed           = True
End Sub
markotxe
Mensajes: 27
Registrado: Jue May 02, 2019 9:47 am

[RESUELTO]: Error en tiempo de ejecucion

Mensaje por markotxe »

Hola FJCC-ES
Funciona de lujo!
Mil gracias al forum, por existir y porque estoy aprendiendo mucho a vuestro contacto.
Pero especial dedicaz a FFJC-ES, Muchas Gracias me ha sacado de un buen apuro (solo no lo habria conseguido)!
OpenOffice 4.1.5 CALC, Window10
Responder