[Solved] Need shortcut key to "Repeat Task" function

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
SienaVB
Posts: 2
Joined: Fri Feb 22, 2019 3:58 pm

[Solved] Need shortcut key to "Repeat Task" function

Post by SienaVB »

I don't know if it's available already. When I convert one row of Table to Text in Writer, I would like to be able to use a shortcut key to repeat that function without going to Table, Convert, etc., for each subsequent table rows.
Last edited by SienaVB on Sat Feb 23, 2019 2:59 pm, edited 1 time in total.
Apache OpenOffice 4.1.6
Windows 10 Pro Version 1809
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Need shortcut key to "Repeat Task" function

Post by Villeroy »

For most commands that would be Ctrl+Shift+Y but the table-to-text command is more specific since it lets you choose a delimiter. The program is not able to do the same as before with the same specifics as before. The following set of macros is a work-around for this limitation. There are 5 callable macros for semicolon, colon, comma, tab, paragraph separated text calling one macro to do the actual job with the given delimiter.
menu:Tools>Macros>Organize>Basic... tab "Modules"
Select the "Standard" library of the "My Macros" container and create a new module.
Paste the following code into the module.
Assign a keyboard shortcut to the macro you need via Tools>Customize>Keyboard. Choose a shortcut, pick the macro from My Macros>Standard>Module>Table2Text_xxx and click the [Modify button].

Code: Select all

REM  *****  BASIC  *****

Sub Table2Text_Semicolon()
	dispatch_Table2Text ";"
End Sub

Sub Table2Text_Colon()
	dispatch_Table2Text ":"
End Sub

Sub Table2Text_Comma()
	dispatch_Table2Text ","
End Sub

Sub Table2Text_Tab()
REM Chr(9) is a tabulator
	dispatch_Table2Text Chr(9)
End Sub

Sub Table2Text_Para()
REM Chr(10) is a paragraph break
	dispatch_Table2Text Chr(10)
End Sub

sub dispatch_Table2Text(sep)
	frame = ThisComponent.CurrentController.Frame
	dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	dim args2(0) as new com.sun.star.beans.PropertyValue
	args2(0).Name = "Delimiter"
	args2(0).Value = sep
	dispatcher.executeDispatch(frame, ".uno:ConvertTableToText", "", 0, args2())
end sub
You can easily add a macro for another delimiter. This is another one for the pipe symbol.

Code: Select all

Sub Table2Text_Pipe()
	dispatch_Table2Text "|"
End Sub

Just put it on the same module. You can also remove the ones you don't need. Just keep "Sub dispatch_Table2Text" because this is the one which actually does the job.
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
SienaVB
Posts: 2
Joined: Fri Feb 22, 2019 3:58 pm

Re: Need shortcut key to "Repeat Task" function

Post by SienaVB »

Thank you for your help. Much appreciated. Siena
Apache OpenOffice 4.1.6
Windows 10 Pro Version 1809
Post Reply