Thank you Andrew. That looks like it's a full answer to the question. I have learned something from
this. I might not use it often but I now have it in my bag of tools and who knows ....
--
Jim
-----Original Message-----
From: Andrew Pitonyak <andrew@pitonyak.org>
To: "James E. Lang" <jelly@lang.hm>
Sent: Mon, 20 Apr 2015 11:40
Subject: Re: [libreoffice-users] [LibreOffice Writer] Table with alternat[]e row color
On 20.04.2015 10:03, James E. Lang wrote:
Hi Andrew,
This message is off list for technical reasons.
No problem, especially for this type of question :-)
As I stated in a message that I posted to the list yesterday, I don't
do a lot of work with
LibreOffice Writer. That said, I tried your macro and it choked
(Sub-procedure or function
procedure not defined) on this line:
SetParStyle(oCell.getText(), "OOoTableHeader")
Yeah, sorry about that. What this is doing is setting the first row to
use the paragraph style named "OOoTableHeader". I don't know if you have
seen any of my documents, but it is how I format my text tables in
general. You can comment out that line, or, change "OOoTableHeader" to
be the paragraph style that you want to use.
There is another line below it
SetParStyle(oCell.getText(), "OOoTableText")
This sets all of the other lines to use the paragraph style
"OOoTableText", which is probably a paragraph style that you do not have
if you do not write documentation for LibreOffice.
Comment out these two lines by placing a single quote before them or
the text REM as follows:
'SetParStyle(oCell.getText(), "OOoTableText")
REM SetParStyle(oCell.getText(), "OOoTableText")
Is this because I don't have the jre installed or is there something
else that is required
(defining the UNO interface maybe?) beyond the Sub you posted?
My Macros=>Standard=>Module1 contains only the empty Sub Main, three
pure Basic (UNO
free) functions that I wrote for a spreadsheet, and your Sub
FormatTable which I copied from
the eMail and pasted into the module.
--
Jim
On 20 Apr 2015 at 8:03, Andrew Douglas Pitonyak wrote:
I wrote a macro some years back and I still use it today. You
probably
have no interest in the part that sets the borders...
Sub FormatTable(Optional oUseTable)
Dim oTable
Dim oCell
Dim nRow As Long
Dim nCol As Long
If IsMissing(oUseTable) Then
oTable =
ThisComponent.CurrentController.getViewCursor().TextTable
Else
oTable = oUseTable
End If
If IsNull(oTable) OR IsEmpty(oTable) Then
Print "FormatTable: No table specified"
Exit Sub
End If
Dim v
Dim x
v = oTable.TableBorder
x = v.TopLine
x.OuterLineWidth = 2
v.TopLine = x
x = v.LeftLine
x.OuterLineWidth = 2
v.LeftLine = x
x = v.RightLine
x.OuterLineWidth = 2
v.RightLine = x
x = v.TopLine
x.OuterLineWidth = 2
v.TopLine = x
x = v.VerticalLine
x.OuterLineWidth = 2
v.VerticalLine = x
x = v.HorizontalLine
x.OuterLineWidth = 0
v.HorizontalLine = x
x = v.BottomLine
x.OuterLineWidth = 2
v.BottomLine = x
'v.Distance = 51
oTable.TableBorder = v
For nRow = 0 To oTable.getRows().getCount() - 1
For nCol = 0 To oTable.getColumns().getCount() - 1
oCell = oTable.getCellByPosition(nCol, nRow)
If nRow = 0 Then
oCell.BackColor = 128
SetParStyle(oCell.getText(), "OOoTableHeader")
Else
SetParStyle(oCell.getText(), "OOoTableText")
If nRow MOD 2 = 1 Then
oCell.BackColor = -1
Else
REM color is (230, 230, 230)
oCell.BackColor = 15132390
End If
End If
Next
Next
End Sub
--
Andrew Pitonyak
--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.