Olá! Estou tentando criar uma macro que, antes de limpar a tabela, crie uma cópia da planilha através do recurso “Salvar Como”. Porém, da forma como fiz, não está funcionando.
Poderiam, por gentileza, verificar o que há de errado?
Grato!
sub Limpar_Tabela
Dim Resposta as Integer
Resposta = MsgBox (“Você tem certeza? O navio já foi salvo?”, 36, “ATENÇÃO”)
If Resposta = 6 Then REM SE RESPOSTA SIM(6)
Call Salvar_como REM MACRO = Macro no caso Positivo (Sim)
else
end if
end sub
sub Salvar_como
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 = “$F$3”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, “.uno:Copy”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = “URL”
args3(0).Value = “file:///Y:/Comando/RELAT%C3%93RIO/TESTE%20-%20LUCKY%20LOONG.ods”
args3(1).Name = “FilterName”
args3(1).Value = “calc8”
dispatcher.executeDispatch(document, “.uno:SaveAs”, “”, 0, args3())
end sub
'-------------------------------------------------------------------------
sub Macro2
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”)
'Bolacha 1
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = “ToPoint”
args1(0).Value = “$F$3:$F$6”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, “.uno:ClearContents”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = “ToPoint”
args7(0).Value = “$P$2”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args7())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, “.uno:ClearContents”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = “ToPoint”
args8(0).Value = “$P$4”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args8())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, “.uno:ClearContents”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = “ToPoint”
args9(0).Value = “$B$10:$M$10”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args9())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, “.uno:ClearContents”, “”, 0, Array())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = “ToPoint”
args11(0).Value = “$N$9:$P$10”
dispatcher.executeDispatch(document, “.uno:GoToCell”, “”, 0, args11())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, “.uno:ClearContents”, “”, 0, Array())