[Solved] Open a dialog to a specific tab (and nothing more)
-
- Posts: 22
- Joined: Thu Mar 14, 2013 1:05 am
[Solved] Open a dialog to a specific tab (and nothing more)
I want a command (menu item or toolbar button) to simply open the 'Format Cells' dialog to the 'Numbers' tab, and nothing more.
I usually record my macros, but when I record this one nothing gets saved.
Can someone tell me the secret to doing this? Do I even need a macro?
I usually record my macros, but when I record this one nothing gets saved.
Can someone tell me the secret to doing this? Do I even need a macro?
Last edited by MrProgrammer on Mon Nov 09, 2020 5:14 pm, edited 3 times in total.
Reason: Add green tick
Reason: Add green tick
-
- Volunteer
- Posts: 1548
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Open a dialog to a specific tab (and nothing more)
The Format Cells dialog saves the tab that was active when the dialog is closed. If you select the Numbers tab before closing the dialog, the next time it will open on the Numbers tab.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
-
- Posts: 22
- Joined: Thu Mar 14, 2013 1:05 am
Re: Open a dialog to a specific tab (and nothing more)
thanks for the reply but I'm looking for a command, i.e., a way to do it via a macro that can be assigned to a menu item or toolbar button.
OpenOffice 4.1.1 on Windows 7 x64
Re: Open a dialog to a specific tab (and nothing more)
Look at Useful Macro Information For OpenOffice By Andrew Pitonyak (free online)
Section 9.7.2. Discovering the accessible content
If you're able to follow it you may be able to write a similar macro for the dialog you want.
Section 9.7.2. Discovering the accessible content
If you're able to follow it you may be able to write a similar macro for the dialog you want.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
-
- Volunteer
- Posts: 1548
- Joined: Wed Jun 24, 2015 12:56 am
- Location: Colorado, USA
Re: Open a dialog to a specific tab (and nothing more)
The macro recorder only records keystrokes (not mouse button clicks or movements) so I recorded a macro using the Format Cells shortcut key Ctrl+1 and got the following code
Code: Select all
REM ***** BASIC *****
sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:FormatCellDialog", "", 0, Array())
end sub
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Re: Open a dialog to a specific tab (and nothing more)
This is Listing 9.10 from above modified. Run the FormatCellDialog sub.
Code: Select all
Sub FormatCellDialog()
Dim oFrame ' Frame from the current window.
Dim oToolkit ' Container window's com.sun.star.awt.Toolkit
Dim oDisp ' Dispatch helper.
Dim oList ' XTopWindowListener that handles the interactions.
Dim s$
REM Get the com.sun.star.awt.Toolkit
oFrame = ThisComponent.getCurrentController().getFrame()
oToolkit = oFrame.getContainerWindow().getToolkit()
s$ = "com.sun.star.awt.XTopWindowListener"
oList = createUnoListener("TopWFormula_", s$)
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
REM Insert an OLE object!
oToolkit.addTopWindowListener(oList)
oDisp.executeDispatch(oFrame, ".uno:FormatCellDialog", "", 0, Array())
oToolkit.removeTopWindowListener(oList)
End Sub
Sub TopWFormula_windowOpened(e As Object)
'Dim oAC
'Dim oACRadioButtonNew
'Dim oACList
'Dim oACButtonOK
'REM Get the accessible window, which is the entire dialog.
'oAC = e.source.AccessibleContext
'REM Get the buttons
'oACRadioButtonNew = oAC.getAccessibleChild(0).AccessibleContext
'DIM oAC2
'oAC2 = oAC.getAccessibleChild(2)
'oACList = oAC2.AccessibleContext.getAccessibleChild(0)
'oACButtonOK = oAC.getAccessibleChild(4).AccessibleContext
'REM Select "Create New"
'oACRadioButtonNew.doAccessibleAction(0)
'REM Access the Fifth item in the list (as in 0, 1, 2, 3, 4...)
'oACList.selectAccessibleChild(4)
'214
'REM The accessible action of a command button is to "use" it.
'oACButtonOK.doAccessibleAction(0)
End Sub
Sub TopWFormula_windowClosing(e As Object)
End Sub
Sub TopWFormula_windowClosed(e As Object)
End Sub
Sub TopWFormula_windowMinimized(e As Object)
End Sub
Sub TopWFormula_windowNormalized(e As Object)
End Sub
Sub TopWFormula_windowActivated(e As Object)
static boo as boolean
if boo = false then
boo = true
e.source.accessiblecontext.getaccessiblechild(0).getaccessiblecontext.selectaccessiblechild(0)
end if
End Sub
Sub TopWFormula_windowDeactivated(e As Object)
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
-
- Posts: 22
- Joined: Thu Mar 14, 2013 1:05 am
Re: Open a dialog to a specific tab (and nothing more)
Thank you JeJe, that looks promising, I'll give it a try and post back.
p.s. took me a while to find that book online but looks really interesting tho will take time to get thru.
Not sure I found the same version you have - in this one that section is 10.7.2)
p.s. took me a while to find that book online but looks really interesting tho will take time to get thru.
Not sure I found the same version you have - in this one that section is 10.7.2)
OpenOffice 4.1.1 on Windows 7 x64
-
- Posts: 22
- Joined: Thu Mar 14, 2013 1:05 am
Re: Open a dialog to a specific tab (and nothing more)
Thank you UnklDonald418 much appreciated, will take a look at that.UnklDonald418 wrote:The macro recorder only records keystrokes (not mouse button clicks or movements) so I recorded a macro using the Format Cells shortcut key Ctrl+1 and got the following code
end sub[/code]
OpenOffice 4.1.1 on Windows 7 x64
-
- Posts: 22
- Joined: Thu Mar 14, 2013 1:05 am
Re: Open a dialog to a specific tab (and nothing more)
Thank you JeJe it works! Excellent! Took me a while to set things up, but it works perfectly.JeJe wrote:This is Listing 9.10 from above modified. Run the FormatCellDialog sub.
Code: Select all
Sub FormatCellDialog() Dim oFrame ' Frame from the current window. Dim oToolkit ' Container window's com.sun.star.awt.Toolkit Dim oDisp ' Dispatch helper. Dim oList ' XTopWindowListener that handles the interactions. Dim s$ REM Get the com.sun.star.awt.Toolkit oFrame = ThisComponent.getCurrentController().getFrame() oToolkit = oFrame.getContainerWindow().getToolkit() s$ = "com.sun.star.awt.XTopWindowListener" oList = createUnoListener("TopWFormula_", s$) oDisp = createUnoService("com.sun.star.frame.DispatchHelper") REM Insert an OLE object! oToolkit.addTopWindowListener(oList) oDisp.executeDispatch(oFrame, ".uno:FormatCellDialog", "", 0, Array()) oToolkit.removeTopWindowListener(oList) End Sub Sub TopWFormula_windowOpened(e As Object) 'Dim oAC 'Dim oACRadioButtonNew 'Dim oACList 'Dim oACButtonOK 'REM Get the accessible window, which is the entire dialog. 'oAC = e.source.AccessibleContext 'REM Get the buttons 'oACRadioButtonNew = oAC.getAccessibleChild(0).AccessibleContext 'DIM oAC2 'oAC2 = oAC.getAccessibleChild(2) 'oACList = oAC2.AccessibleContext.getAccessibleChild(0) 'oACButtonOK = oAC.getAccessibleChild(4).AccessibleContext 'REM Select "Create New" 'oACRadioButtonNew.doAccessibleAction(0) 'REM Access the Fifth item in the list (as in 0, 1, 2, 3, 4...) 'oACList.selectAccessibleChild(4) '214 'REM The accessible action of a command button is to "use" it. 'oACButtonOK.doAccessibleAction(0) End Sub Sub TopWFormula_windowClosing(e As Object) End Sub Sub TopWFormula_windowClosed(e As Object) End Sub Sub TopWFormula_windowMinimized(e As Object) End Sub Sub TopWFormula_windowNormalized(e As Object) End Sub Sub TopWFormula_windowActivated(e As Object) static boo as boolean if boo = false then boo = true e.source.accessiblecontext.getaccessiblechild(0).getaccessiblecontext.selectaccessiblechild(0) end if End Sub Sub TopWFormula_windowDeactivated(e As Object) End Sub
p.s. Which version of 'Useful Macro Information For OpenOffice.org' do you use?
The one I found is Document Revision: 1140 dated June 12, 2015. I was looking in it for something similar to your code, to try to follow it.
Last edited by cookieJones on Mon Nov 09, 2020 3:55 am, edited 1 time in total.
OpenOffice 4.1.1 on Windows 7 x64
-
- Posts: 22
- Joined: Thu Mar 14, 2013 1:05 am
Re: Open a dialog to a specific tab (and nothing more)
UnklDonald418 wrote:The macro recorder only records keystrokes (not mouse button clicks or movements) so I recorded a macro using the Format Cells shortcut key Ctrl+1 and got the following code
Code: Select all
REM ***** BASIC ***** sub Main rem ---------------------------------------------------------------------- rem define variables dim document as object dim dispatcher as object rem ---------------------------------------------------------------------- rem get access to the document document = ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:FormatCellDialog", "", 0, Array()) end sub
Thank you UnklDonald418, this almost works except that it opens to the last used tab, not necessarily the numbers tab (as you noted in your first post) but it definitely brings up the correct dialog.
OpenOffice 4.1.1 on Windows 7 x64
Re: [SOLVED] Open a dialog to a specific tab (and nothing mo
My version has Last Modified
Wednesday, January 25, 2006 at 03:48:07 PM
The original listing I modified is:
Wednesday, January 25, 2006 at 03:48:07 PM
The original listing I modified is:
Code: Select all
Listing 9.10: Insert a formula into writer.
Sub InsertFormulaIntoWriter()
Dim oFrame ' Frame from the current window.
Dim oToolkit ' Container window's com.sun.star.awt.Toolkit
Dim oDisp ' Dispatch helper.
Dim oList ' XTopWindowListener that handles the interactions.
Dim s$
REM Get the com.sun.star.awt.Toolkit
oFrame =ThisComponent.getCurrentController().getFrame()
oToolkit = oFrame.getContainerWindow().getToolkit()
s$ = "com.sun.star.awt.XTopWindowListener"
oList = createUnoListener("TopWFormula_", s$)
oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
REM Insert an OLE object!
oToolkit.addTopWindowListener(oList)
oDisp.executeDispatch(oFrame, ".uno:InsertObject", "", 0, Array())
oToolkit.removeTopWindowListener(oList)
End Sub
Sub TopWFormula_windowOpened(e As Object)
Dim oAC
Dim oACRadioButtonNew
Dim oACList
Dim oACButtonOK
REM Get the accessible window, which is the entire dialog.
oAC = e.source.AccessibleContext
REM Get the buttons
oACRadioButtonNew = oAC.getAccessibleChild(0).AccessibleContext
DIM oAC2
oAC2 = oAC.getAccessibleChild(2)
oACList = oAC2.AccessibleContext.getAccessibleChild(0)
oACButtonOK = oAC.getAccessibleChild(4).AccessibleContext
REM Select "Create New"
oACRadioButtonNew.doAccessibleAction(0)
REM Access the Fifth item in the list (as in 0, 1, 2, 3, 4...)
oACList.selectAccessibleChild(4)
214
REM The accessible action of a command button is to "use" it.
oACButtonOK.doAccessibleAction(0)
End Sub
Sub TopWFormula_windowClosing(e As Object)
End Sub
Sub TopWFormula_windowClosed(e As Object)
End Sub
Sub TopWFormula_windowMinimized(e As Object)
End Sub
Sub TopWFormula_windowNormalized(e As Object)
End Sub
Sub TopWFormula_windowActivated(e As Object)
End Sub
Sub TopWFormula_windowDeactivated(e As Object)
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
-
- Posts: 22
- Joined: Thu Mar 14, 2013 1:05 am
Re: [Solved] Open a dialog to a specific tab (and nothing mo
Found it - in the version I have, it's Listing 10.2.
I see you did a lot of changes to make it work for my case -
THANK YOU so much. I never would have figured it out.
I see you did a lot of changes to make it work for my case -
THANK YOU so much. I never would have figured it out.
OpenOffice 4.1.1 on Windows 7 x64