Difference between revisions of "ES/Desarrollo/Macros"
From Apache OpenOffice Wiki
< ES
(→Algunos ejemplos sencillos) |
(→Algunos ejemplos sencillos) |
||
Line 9: | Line 9: | ||
− | + | Author: Stephan Wunderlich [stephan.wunderlich@sun.com] | |
<code> [basic] | <code> [basic] | ||
+ | |||
Sub CopySpreadsheet | Sub CopySpreadsheet | ||
firstDoc = ThisComponent | firstDoc = ThisComponent | ||
+ | |||
+ | En las siguientes 3 líneas le decimos a OpenOffice que seleccione en esta planilla | ||
+ | todas las celdas cree una nueva hoja y las copie | ||
+ | |||
selectSheetByName(firstDoc, "Sheet2") | selectSheetByName(firstDoc, "Sheet2") | ||
dispatchURL(firstDoc,".uno:SelectAll") | dispatchURL(firstDoc,".uno:SelectAll") | ||
dispatchURL(firstDoc,".uno:Copy") | dispatchURL(firstDoc,".uno:Copy") | ||
secondDoc = StarDesktop.loadComponentFromUrl("private:factory/scalc","_blank",0,dimArray()) | secondDoc = StarDesktop.loadComponentFromUrl("private:factory/scalc","_blank",0,dimArray()) | ||
+ | |||
+ | Luego de copiar las celdas las insertamos en la nuevo hoja | ||
+ | |||
secondDoc.getSheets().insertNewByName("inserted",0) | secondDoc.getSheets().insertNewByName("inserted",0) | ||
selectSheetByName(secondDoc, "inserted") | selectSheetByName(secondDoc, "inserted") | ||
Line 23: | Line 31: | ||
End Sub | End Sub | ||
− | + | ||
Sub selectSheetByName(document, sheetName) | Sub selectSheetByName(document, sheetName) |
Revision as of 10:26, 26 December 2007
Programación en Macros
Algunos ejemplos sencillos
- Este ejemplo sirve para copiar el contenido de una planilla e insertarla en un segundo documento creado .
Author: Stephan Wunderlich [stephan.wunderlich@sun.com]
[basic]
Sub CopySpreadsheet
firstDoc = ThisComponent
En las siguientes 3 líneas le decimos a OpenOffice que seleccione en esta planilla
todas las celdas cree una nueva hoja y las copie
selectSheetByName(firstDoc, "Sheet2") dispatchURL(firstDoc,".uno:SelectAll") dispatchURL(firstDoc,".uno:Copy") secondDoc = StarDesktop.loadComponentFromUrl("private:factory/scalc","_blank",0,dimArray())
Luego de copiar las celdas las insertamos en la nuevo hoja
secondDoc.getSheets().insertNewByName("inserted",0) selectSheetByName(secondDoc, "inserted") dispatchURL(secondDoc,".uno:Paste")
End Sub
Sub selectSheetByName(document, sheetName)
End Sub
Sub dispatchURL(document, aURL)
Dim noProps() Dim URL As New com.sun.star.util.URL
frame = document.getCurrentController().getFrame() URL.Complete = aURL transf = createUnoService("com.sun.star.util.URLTransformer") transf.parseStrict(URL)
disp = frame.queryDispatch(URL, "", com.sun.star.frame.FrameSearchFlag.SELF _ OR com.sun.star.frame.FrameSearchFlag.CHILDREN) disp.dispatch(URL, noProps())
End Sub