| View previous topic :: View next topic |
| Author |
Message |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Mon Feb 09, 2009 10:01 am Post subject: [Solved] add brackets to selected test |
|
|
I need a macro that adds brackets at the beginning and at the end of a selected text in OOo Writer.
This is an example:
“ this a template text line in writer ”
i select with my mouse the words “text line”
then i run the macro, and it turns into:
“ this a template [text line] in writer ”
do u undestand what i mean and think this can be done?
Last edited by Tommy27 on Sun Mar 08, 2009 3:41 pm; edited 1 time in total |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Mon Feb 09, 2009 11:50 am Post subject: |
|
|
well i need this macro in any language i write....
my O/S in Win VIsta 64but SP1
thanks for the link but unfortunatately i'm pretty analphabet about macro code. |
|
| Back to top |
|
 |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Tue Feb 10, 2009 11:39 am Post subject: |
|
|
i got the right suggestion from the Italian OOo Google Groups (thanks to Roberto Montaruli).
i just started the macro recorder with a selected word
then hit Ctrl-X,
then type [
then Ctrl-V,
then type ]
stop the macro recorder
here's the final code
| Code: | sub ParentesiQuadre
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:Cut", "", 0, Array())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Text"
args2(0).Value = "["
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args2())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Text"
args4(0).Value = "]"
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args4())
end sub |
|
|
| Back to top |
|
 |
|