Page 1 of 1

[Solved] Form Control Visible/Invisible with macro

PostPosted: Tue Feb 02, 2010 1:44 pm
by ottoshmidt
Hi,

Form Controls in ooo 3.2 have option Visible (Yes, No)... Can I access that property with macros?

I have tried: .visbible = 0 (just like .enabled = 0) but that didn't work...

Is there any possible way?

Re: Form Control Visible/Invisible with macro

PostPosted: Tue Feb 02, 2010 10:03 pm
by FJCC
This Basic code toggles the Visible property of a button with a 3 second delay between making it invisible and visible.
Code: Select all   Expand viewCollapse view
Doc = ThisComponent
Sheet = Doc.Sheets.getByIndex(0)
Page = Sheet.DrawPage
Form = Page.Forms.getByIndex(0)
Button = Form.getByName("PushButton")
ButtonCtrl = Doc.CurrentController.getControl(Button)
ButtonCtrl.setVisible(False)
Wait 3000
ButtonCtrl.setVisible(True)

'Button is an object of type com.sun.star.comp.forms.OButtonModel
'ButtonCtrl is an object of type com.sun.star.comp.forms.OButtonControl  This can control object size position visibility etc

Re: Form Control Visible/Invisible with macro

PostPosted: Wed Feb 03, 2010 2:35 am
by MikeytheMagnificent
Sorry, I'm new to all this Macro stuff, perhaps RJCC or ANother could explain if any/or most of this sort of code generates itself as it creates the macro or if you must sit before a blank sheet and amaze me how you've ever became so clever?

Admiration

Re: Form Control Visible/Invisible with macro

PostPosted: Wed Feb 03, 2010 3:16 am
by FJCC
Macro code usually has to be written from scratch. The macro recorder will handle simple cases, but quickly loses usefulness. A good place to learn about macros is Andrew Pitonyak's English Macro Document.

Re: Form Control Visible/Invisible with macro

PostPosted: Fri Feb 05, 2010 9:06 am
by ottoshmidt
FJCC wrote:This Basic code toggles the Visible property of a button with a 3 second delay between making it invisible and visible.
Code: Select all   Expand viewCollapse view
Doc = ThisComponent
Sheet = Doc.Sheets.getByIndex(0)
Page = Sheet.DrawPage
Form = Page.Forms.getByIndex(0)
Button = Form.getByName("PushButton")
ButtonCtrl = Doc.CurrentController.getControl(Button)
ButtonCtrl.setVisible(False)
Wait 3000
ButtonCtrl.setVisible(True)

'Button is an object of type com.sun.star.comp.forms.OButtonModel
'ButtonCtrl is an object of type com.sun.star.comp.forms.OButtonControl  This can control object size position visibility etc



Hugely Thankful ;)