Página 1 de 1

[RESUELTO] Error en tiempo de ejecución

Publicado: Jue May 02, 2019 11:34 am
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

Re: Error en tiempo de ejecucion

Publicado: Jue May 02, 2019 4:44 pm
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.

Re: Error en tiempo de ejecucion

Publicado: Jue May 02, 2019 11:38 pm
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?

Re: Error en tiempo de ejecucion

Publicado: Vie May 03, 2019 4:44 am
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

[RESUELTO]: Error en tiempo de ejecucion

Publicado: Vie May 03, 2019 1:54 pm
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)!