Ok, after a lot of playing around I think I have it. The line I needed is
oIndex.setPropertyValue ( “Level”, 4)
I changed the xIndex to oIndex, in keeping with the rest of the code. Then I simplified the parameters to be “parameter”, value. It seems to be working.
The working macro is at http://pastebin.com/MPWbEPBd
(I’m not sure why multiple lines of code are not formatted properly on this site).
Now I will try to figure out how to update only a specific Index.
Thanks for all the help.
EDIT: Actually, I’m getting buggy performance from that line. It worked fine yesterday, but today I consistently get one level higher than what I set.
(Edited by @Lupp To insert multiline code you need:
-
A blank line between the preceding text and the code.
-
4 contiguous spaces prefixed to each line of code as a syntactical indicator.
(I won’t comment on the Sub itself. I just quote it as an example for the usage of the above guide.)
Sub SetIndex
’ see: Indexes and Index Marks - Apache OpenOffice Wiki
oSelection = ThisComponent.CurrentController.Selection
oIndex =ThisComponent.createInstance(“com.sun.star.text.ContentIndexMark”)
oIndex.setPropertyValue ( “Level”, 4)
for Int1 = 0 to oSelection.Count -1
oSel1 = oSelection (Int1)
if HasUnoInterfaces(oSel1,“com.sun.star.text.XTextRange”) Then
ThisComponent.Text.InsertTextContent(oSel1, oIndex, True)
end If
Next Int1
Update_Index 'Call Sub Update_Index
End Sub