Ask Your Question
0

Libre Office Writer character border macro not working

asked 2017-01-15 22:24:54 +0200

dcweaver01 gravatar image

updated 2017-06-28 16:31:24 +0200

I've created a macro for a code block (alters selected paragraph style):

code block

I also tried creating the same macro for in-line code (alters selected character style) but with no success - the macro doesn't apply the border:

inline code

This is what I want the end result to be:

inline code with a border

The macro doesn't apply the border style to the selected characters. Even though it's done through the same interface that I used for the paragraph styling.

Below is the macro code that is generated when adding a simple border around selected text.

Any ideas as to why the border doesn't get applied?

sub addBorder
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:BorderInner", "", 0, Array())


end sub
edit retag flag offensive close merge delete

Comments

Please stick to the essentials. Don't force people to read a lot of code that isn't relevant to your question.

floris v gravatar imagefloris v ( 2017-01-16 22:17:54 +0200 )edit

The code is only there for reference, this forum doesn't have a folding of code blocks so it shows all of it. I purposefully put everything on top of the page. I don't see a problem.

dcweaver01 gravatar imagedcweaver01 ( 2017-01-16 22:40:50 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-03-25 19:11:17 +0200

G o r d gravatar image

I too struggled with this until I finally and got it to work. Here is the key point:

  • Sometimes the 'Record Macro' doesn't work for clicking on toolbar shortcuts and you have to record going through the menus.

Example: What follows is an example to get a thick bottom border

sub BottomLineHeavy

rem ---- This macro was recorded using:
rem -- "Format (Alt+'0'), Cells (Alt+'l'+'Enter'), User-defined (Alt+'u' then use cursor keys
rem -- to navigate and spacebar to select sides - also note that the left side may be
rem -- selected by default - pressing the spacebar three times cycles through your
rem -- choices), Tab to Style (cursor up and down to select) then tab to Width to set
rem -- line thickness."

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 ----------------------------------------------------------------------

dim args1(7) as new com.sun.star.beans.PropertyValue
args1(0).Name = "BorderOuter.LeftBorder"
args1(0).Value = Array(0,0,0,0,0,0)
args1(1).Name = "BorderOuter.LeftDistance"
args1(1).Value = 0
args1(2).Name = "BorderOuter.RightBorder"
args1(2).Value = Array(0,0,0,0,0,0)
args1(3).Name = "BorderOuter.RightDistance"
args1(3).Value = 0
args1(4).Name = "BorderOuter.TopBorder"
args1(4).Value = Array(0,0,0,0,0,0)
args1(5).Name = "BorderOuter.TopDistance"
args1(5).Value = 0
args1(6).Name = "BorderOuter.BottomBorder"
args1(6).Value = Array(0,0,44,0,0,44)
args1(7).Name = "BorderOuter.BottomDistance"
args1(7).Value = 0

dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1())

end sub
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-01-15 22:24:54 +0200

Seen: 143 times

Last updated: Mar 25