[Solved] Editing Style Properties through VB Macro

Keyboard macros or custom scripts

[Solved] Editing Style Properties through VB Macro

Postby vit123 » Fri Feb 26, 2010 2:25 pm

Hi Friends! I'm a newbie to OOo Writer (using v3.2 on WinXP)
I tried everything to record a VB macro that might let me change a preset paragraph (or character) style:
I've got some text set in "myStyle" style which is set "black", I don't mean to change directly the text style or property, but I wish to change "myStyle"'s colour property to "red" through a macro (I'll link to a button; another button will link a similar Macro doing the contrary: a fast way to switch view)
Recording a Macro I get this code:
...
args1(0).Name = "Param"
args1(0).Value = "myStyle"
args1(1).Name = "Family"
args1(1).Value = 1
dispatcher.executeDispatch(document, ".uno:EditStyle", "", 0, args1())
...
but running it just allows me to open the Edit Style Dialog Window, it seems it cannot record any setting..
I guess I need to complete the code manually by mysef somehow:
May you help me to get a sample VB code to change properties of a named Style through a Macro?

Thanks anybody for your time,
Vittorio (Italy)
Last edited by Hagar Delest on Fri Feb 26, 2010 10:42 pm, edited 1 time in total.
Reason: tagged [Solved].
OOo 3.2 on MS Windows XP
vit123
 
Posts: 8
Joined: Fri Feb 26, 2010 1:56 pm

Re: Editing Style Properties through VB Macro

Postby Villeroy » Fri Feb 26, 2010 3:18 pm

You've got to program utilizing the UNO API. Dispatches from the macro recorder do not help.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26977
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Editing Style Properties through VB Macro

Postby vit123 » Fri Feb 26, 2010 4:03 pm

You've got to program utilizing the UNO API

yes, I feared that, please could you post here any raw code (e.g.for editing a "paragraph style property") as an example I can start from?
I would greatly appreciate
Thanks again,
V.
OOo 3.2 on MS Windows XP
vit123
 
Posts: 8
Joined: Fri Feb 26, 2010 1:56 pm

Re: Editing Style Properties through VB Macro

Postby Villeroy » Fri Feb 26, 2010 4:11 pm

http://www.oooforum.org/forum/search.phtml enter "stylefamilies" and get 163 results.
This forum has another 40 hits.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26977
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Editing Style Properties through VB Macro

Postby vit123 » Fri Feb 26, 2010 6:25 pm

Many THANKS to Villeroy for the useful link and the "magic" little word to search (it was just what I missed)!
I would suggest to anyone interested also:
- http://wiki.services.openoffice.org/wik ... nformation (great reference link list, particularly the ODT manual http://www.pitonyak.org/AndrewMacro.odt)
- http://api.openoffice.org/docs/common/r ... ttomBorder (for official detail reference)
Finally I wish to feed this forum posting my own new-born solution to the above mentioned matter:
Code: Select all   Expand viewCollapse view
sub Stampa
   Dim oStileCar,oStilePar
   oStileCar=thisComponent.StyleFamilies.getByName("CharacterStyles").getByName("VitCar")
   oStilePar=thisComponent.StyleFamilies.getByName("ParagraphStyles").getByName("VitStile")
   dim bordo as New com.sun.star.table.BorderLine
   If oStileCar.CharColor=13421772 Then rem STAMPA
      oStileCar.CharColor=16777215
      bordo.Color=0
      bordo.OuterLineWidth=0
   Else rem NO STAMPA
      oStileCar.CharColor=13421772
      bordo.Color=15132390
      bordo.OuterLineWidth=2
   End If
   oStilePar.BottomBorder=bordo
rem Print  oStilePar.BottomBorder.Color
rem 13421772 GRIGIO CHIARO
rem 16777215 BIANCO
rem 15132390 GRIGIO CHIARISSIMO
rem 0 NERO
end sub

it does EXACTLY the switching I meant!
P.S. Just arrived to OOo, but it really looks GREAT

My Best Regards and thanks once again,
Vittorio (Italy)
OOo 3.2 on MS Windows XP
vit123
 
Posts: 8
Joined: Fri Feb 26, 2010 1:56 pm

Re: [Solved] Editing Style Properties through VB Macro

Postby ivants » Mon Sep 05, 2011 2:43 pm

Hi
Please help me to write little macro in OpenOffice Basic, because I know just how to use macros recorder, not to programming it.
I'm just need change paragraph justification in style "MyBasic" to both border through macro.
Thanks, and sorry for my english.
OpenOffice 3.2.1 on Windows 7
ivants
 
Posts: 1
Joined: Mon Sep 05, 2011 2:36 pm

Re: [Solved] Editing Style Properties through VB Macro

Postby Hagar Delest » Mon Sep 05, 2011 4:42 pm

Look at the Macro forum, there is a sticky with links to documentation. Or search for a similar topic with a code snippet.
AOO 4.1.6 on Xubuntu 19.04 and 4.1.5 on Windows 7 (with winPenPack port).

Off-line until Aug. 31.
User avatar
Hagar Delest
Moderator
 
Posts: 28529
Joined: Sun Oct 07, 2007 9:07 pm
Location: France


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest