[SOLVED] Code to execute next Tab

Creating and using forms
Post Reply
Jjs2060
Posts: 60
Joined: Sat Nov 08, 2014 2:53 am

[SOLVED] Code to execute next Tab

Post by Jjs2060 »

Is there code I could put at the end of a macro that will execute the next Tab position?
Last edited by RoryOF on Sat May 30, 2015 6:20 pm, edited 2 times in total.
Reason: Added green tick [RoryOF, Moderator]
Libre Office 4.2.2.1 on OS X 10.9.3
Arineckaig
Volunteer
Posts: 828
Joined: Fri Nov 30, 2007 10:58 am
Location: Scotland

Re: Code to execute next Tab

Post by Arineckaig »

Nothing simple as it would probably require the macro to be pre-programmed with an array of form controls listed in tab order.
When this issue has been resolved, it would help other users of the forum if you add the word - [Solved] - to the Subject line of your 1st post (edit button top right).
AOOo 4.1.5 & LO 6 on MS Windows 10 MySQL and HSQLDB
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Code to execute next Tab

Post by Villeroy »

Arineckaig wrote:Nothing simple as it would probably require the macro to be pre-programmed with an array of form controls listed in tab order.
objForm.getControlModels() returns an array of control models in tab order but you have to weed out the labels, hidden controls and may be some other controls.

Code: Select all

Sub test_getTabControls()
f = thiscomponent.drawpage.forms.getbyindex(0)
a() = getTabControls(f)
dim s$
for each m in a()
	s = s & m.Name & Chr(10)
next
msgbox s
End Sub

Function getTabControls(f)
REM return array of controls that can be tabbed into
Dim a()
for each m in f.getControlModels()
	if m.PropertySetInfo.hasPropertyByName("Tabstop") then
		if isEmpty(m.Tabstop) or m.Tabstop = True then
			if m.Enabled and m.EnableVisible then bas_PushArray(a(), m)
		endif
	endif
next
getTabControls = a()
End Function

'very simple routine appending some element to an array which can be undimensioned (LBound > UBound)
Sub bas_PushArray(xArray(),vNextElement)
Dim iUB%,iLB%
	iLB = lBound(xArray())
	iUB = uBound(xArray())
	If iLB > iUB then
		iUB = iLB
		redim xArray(iLB To iUB)
	else
		iUB = iUB +1
		redim preserve xArray(iLB To iUB)
	endif
	xArray(iUB) = vNextElement
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Jjs2060
Posts: 60
Joined: Sat Nov 08, 2014 2:53 am

Re: [SOLVED]Code to execute next Tab

Post by Jjs2060 »

Thanks.
Libre Office 4.2.2.1 on OS X 10.9.3
Post Reply