Pergunte aqui

Histórico de revisões [voltar]

Vamos lá para o desafio:

em (A1) b1+b2 , em (B1) 1 , em (B2) 2

em (A4) =CONCATENAR("=SOMA("&A1&")")

Gravei a seguinte Macro:

sub teste

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 ----------------------------------------------------------------------

dim args1(0) as new com.sun.star.beans.PropertyValue

args1(0).Name = "ToPoint"

args1(0).Value = "$A$4"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------

dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

rem ----------------------------------------------------------------------

dim args3(0) as new com.sun.star.beans.PropertyValue

args3(0).Name = "ToPoint"

args3(0).Value = "$A$15"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())

rem ----------------------------------------------------------------------

dim args4(5) as new com.sun.star.beans.PropertyValue

args4(0).Name = "Flags"

args4(0).Value = "SDNT"

args4(1).Name = "FormulaCommand"

args4(1).Value = 0

args4(2).Name = "SkipEmptyCells"

args4(2).Value = false

args4(3).Name = "Transpose"

args4(3).Value = false

args4(4).Name = "AsLink"

args4(4).Value = false

args4(5).Name = "MoveMode"

args4(5).Value = 4

dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args4())

rem ----------------------------------------------------------------------

dispatcher.executeDispatch(document, ".uno:SetInputMode", "", 0, Array())

rem ----------------------------------------------------------------------

dim args6(0) as new com.sun.star.beans.PropertyValue

args6(0).Name = "StringName"

args6(0).Value = "==SOMA(b1+b2)"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args6())

end sub

Ai você completa com Enter. E o resultado na célula deu 3.

clique para ocultar/mostrar a revisão 2
No.2 Revision

Vamos lá para o desafio:

em (A1) b1+b2 , em (B1) 1 , em (B2) 2

em (A4) =CONCATENAR("=SOMA("&A1&")")

Gravei a seguinte Macro:

sub teste

rem ----------------------------------------------------------------------

teste rem ---------------------------------------------------------------------- rem define variables

variables dim document as object

object dim dispatcher as object

rem ----------------------------------------------------------------------

object rem ---------------------------------------------------------------------- rem get access to the document

document document = ThisComponent.CurrentController.Frame

ThisComponent.CurrentController.Frame dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------

createUnoService("com.sun.star.frame.DispatchHelper") rem ---------------------------------------------------------------------- dim args1(0) as new com.sun.star.beans.PropertyValue

com.sun.star.beans.PropertyValue args1(0).Name = "ToPoint"

"ToPoint" args1(0).Value = "$A$4"

"$A$4" dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------

args1()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

rem ----------------------------------------------------------------------

Array()) rem ---------------------------------------------------------------------- dim args3(0) as new com.sun.star.beans.PropertyValue

com.sun.star.beans.PropertyValue args3(0).Name = "ToPoint"

"ToPoint" args3(0).Value = "$A$15"

"$A$15" dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())

rem ----------------------------------------------------------------------

args3()) rem ---------------------------------------------------------------------- dim args4(5) as new com.sun.star.beans.PropertyValue

com.sun.star.beans.PropertyValue args4(0).Name = "Flags"

"Flags" args4(0).Value = "SDNT"

"SDNT" args4(1).Name = "FormulaCommand"

"FormulaCommand" args4(1).Value = 0

0 args4(2).Name = "SkipEmptyCells"

"SkipEmptyCells" args4(2).Value = false

false args4(3).Name = "Transpose"

"Transpose" args4(3).Value = false

false args4(4).Name = "AsLink"

"AsLink" args4(4).Value = false

false args4(5).Name = "MoveMode"

"MoveMode" args4(5).Value = 4

4 dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args4())

rem ----------------------------------------------------------------------

args4()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:SetInputMode", "", 0, Array())

rem ----------------------------------------------------------------------

Array()) rem ---------------------------------------------------------------------- dim args6(0) as new com.sun.star.beans.PropertyValue

com.sun.star.beans.PropertyValue args6(0).Name = "StringName"

"StringName" args6(0).Value = "==SOMA(b1+b2)"

"==SOMA(b1+b2)" dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args6())

args6()) end sub

sub

Ai você completa com Enter. E o resultado na célula deu 3.

Vamos lá para o desafio:

em (A1) b1+b2 , em (B1) 1 , em (B2) 2

em (A4) =CONCATENAR("=SOMA("&A1&")")

Gravei a seguinte Macro:

sub teste

rem ----------------------------------------------------------------------

rem ----------------------------------------------------------------------
rem define variables
 dim document   as object
 dim dispatcher as object

rem ----------------------------------------------------------------------

rem ----------------------------------------------------------------------
rem get access to the document
 document   = ThisComponent.CurrentController.Frame
 dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
 args1(0).Name = "ToPoint"
 args1(0).Value = "$A$4"
 dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

rem ----------------------------------------------------------------------

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
 args3(0).Name = "ToPoint"
 args3(0).Value = "$A$15"
 dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())

rem ----------------------------------------------------------------------

rem ----------------------------------------------------------------------
dim args4(5) as new com.sun.star.beans.PropertyValue
 args4(0).Name = "Flags"
 args4(0).Value = "SDNT"
 args4(1).Name = "FormulaCommand"
 args4(1).Value = 0
 args4(2).Name = "SkipEmptyCells"
 args4(2).Value = false
 args4(3).Name = "Transpose"
 args4(3).Value = false
 args4(4).Name = "AsLink"
 args4(4).Value = false
 args4(5).Name = "MoveMode"
 args4(5).Value = 4
 dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args4())

rem ----------------------------------------------------------------------

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SetInputMode", "", 0, Array())

rem ----------------------------------------------------------------------

rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
 args6(0).Name = "StringName"
 args6(0).Value = "==SOMA(b1+b2)"
 dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args6())
 end sub

Ai você completa com Enter. E o resultado na célula deu 3.