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

Creating a macro - Writing a Script - Using the API

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

Postby SienaVB » Fri Feb 22, 2019 4:07 pm

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
SienaVB
 
Posts: 2
Joined: Fri Feb 22, 2019 3:58 pm

Re: Need shortcut key to "Repeat Task" function

Postby Villeroy » Sat Feb 23, 2019 2:54 pm

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   Expand viewCollapse view
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   Expand viewCollapse view
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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26417
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Need shortcut key to "Repeat Task" function

Postby SienaVB » Sat Feb 23, 2019 2:57 pm

Thank you for your help. Much appreciated. Siena
Apache OpenOffice 4.1.6
Windows 10 Pro Version 1809
SienaVB
 
Posts: 2
Joined: Fri Feb 22, 2019 3:58 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 11 guests