[Solved] Macro to set cell borders and all inner lines

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
MATT.B
Posts: 165
Joined: Tue Nov 18, 2014 2:16 am

[Solved] Macro to set cell borders and all inner lines

Post by MATT.B »

from cells B50-R50 I would like to set all borders and all inner lines to black and 2.5 pt using a macro
Last edited by MATT.B on Wed Dec 18, 2019 9:19 pm, edited 1 time in total.
OpenOffice 4.1.1 ON WINDOWS 7 64
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: macro to set cell borders and all inner lines

Post by John_Ha »

Search the forum with cell borders for many posts including my post with the bug and the workaround.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
MATT.B
Posts: 165
Joined: Tue Nov 18, 2014 2:16 am

Re: macro to set cell borders and all inner lines

Post by MATT.B »

I have been searching for a while now and all i can find is code that uses con.star.beans or what ever it is and i dont understand that method. Is there a way of doing this a diferent way?
OpenOffice 4.1.1 ON WINDOWS 7 64
MATT.B
Posts: 165
Joined: Tue Nov 18, 2014 2:16 am

Re: macro to set cell borders and all inner lines

Post by MATT.B »

Im still learning i have gotten good figuring out stuff but when it comes to use that method im still very new.
OpenOffice 4.1.1 ON WINDOWS 7 64
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: macro to set cell borders and all inner lines

Post by Zizi64 »

Create a user defined Cell Style with double lined cell border (manually or programatically), and apply that Cell Style by your macro code to the desired cell/cell range.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro to set cell borders and all inner lines

Post by JeJe »

Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
MATT.B
Posts: 165
Joined: Tue Nov 18, 2014 2:16 am

Re: macro to set cell borders and all inner lines

Post by MATT.B »

thank you this was helpfull. but quick question why does this work

Code: Select all

Cell = Sheet.getCellRangeByName("D1")
NewBorder = Cell.BottomBorder
NewBorder.OuterLineWidth = 88
Cell.BottomBorder = NewBorder
but this doesnt work
 Edit:  it does work i had a typo

Code: Select all

Cell = Sheet.getCellRangeByName("D1")
NewBorder = Cell.BottomBorder
NewBorder.OuterLineWidth = 88
'rem i changed this line
NewBorder = NewBorder 
 
OpenOffice 4.1.1 ON WINDOWS 7 64
MATT.B
Posts: 165
Joined: Tue Nov 18, 2014 2:16 am

Re: [solved]Macro to set cell borders and all inner lines

Post by MATT.B »

code that worked for me

Code: Select all

oDoc = ThisComponent
osheets = odoc.getSheets()
osheet = osheets.getByIndex(0)
oCells = oSheet.getCellRangeByName("B50:R50")
NewBorder = oCells.BottomBorder
NewBorder.OuterLineWidth = 88
oCells.BottomBorder = NewBorder
NewBorder = oCells.TopBorder
NewBorder.OuterLineWidth = 88
oCells.sTopBorder = NewBorder
NewBorder = oCells.LeftBorder
NewBorder.OuterLineWidth = 88
oCells.LeftBorder = NewBorder
NewBorder = oCells.RightBorder
NewBorder.OuterLineWidth = 88
ocells.RightBorder = NewBorder
OpenOffice 4.1.1 ON WINDOWS 7 64
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [solved]Macro to set cell borders and all inner lines

Post by RoryOF »

Look at
http://www.openoffice.org/api/docs/comm ... rties.html

I think TableBorder might do the same as your four separate sides. - no, it will only border the entire range.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply