[Solved] Form Control Visible/Invisible with macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
ottoshmidt
Posts: 32
Joined: Tue Dec 29, 2009 9:17 pm
Location: Tbilisi, Georgia

[Solved] Form Control Visible/Invisible with macro

Post 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?
Last edited by ottoshmidt on Fri Feb 05, 2010 9:07 am, edited 1 time in total.
Debian/testing - Openoffice.org 3.2.1 (go-oo version)

[Solved] mark in title significantly facilitates the work of those who try to help. So please, be gentle and don't forget to insert it. ;)

IRC: /join #openoffice.org on irc.freenode.net
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Form Control Visible/Invisible with macro

Post 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

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
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
MikeytheMagnificent
Posts: 137
Joined: Fri Apr 11, 2008 12:06 am
Location: W. Yorks UK

Re: Form Control Visible/Invisible with macro

Post 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
Many opportunities to add short Tutorials or faq's are missed

1. Must have obvious title to be found easily
2. Keep to objectives
3. Use very clear language
4. Difficult to get right
5. Rewards are few
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Form Control Visible/Invisible with macro

Post 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.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
ottoshmidt
Posts: 32
Joined: Tue Dec 29, 2009 9:17 pm
Location: Tbilisi, Georgia

Re: Form Control Visible/Invisible with macro

Post 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

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 ;)
Debian/testing - Openoffice.org 3.2.1 (go-oo version)

[Solved] mark in title significantly facilitates the work of those who try to help. So please, be gentle and don't forget to insert it. ;)

IRC: /join #openoffice.org on irc.freenode.net
Post Reply