Macro depend of action button position!!!

Hi, I have a problem, I have a macro essencialy to copy paste a large number of cell and is called by an action button.
I have my left part of sheet fixed and if I put my action button on right side of fixed cells, macro works, if i move button to left part, it does’t work… It very strange.
Someone have an idea of what is hapened?
Sory my bad English is not my mpther language.
Regard.
Marcoteste.ods

Did you design the “macro” yourself? Is it in BASIC? Did you try to debug it? Does it contain any lines referring to a “Model” or a “Context” or something like that? Why was it not posted? In what way, exactly, does it “not work”? (Excuse the silly question.) After moving the button: Did you toggle design mode back?

Please upload a copy of your Calc document containing the sheet and the macro in question.

To upload your file, click on “edit” under your question, then click on the Paperclip icon.

Hi, this is the code:
Have 3 Modules:

-----NovoEleminaLinhas - (Delete lines)

-----NovoInserirLinhas - (Insert Lines)

-----COPIARLINHAS - (Copy the line A20:CZ20 to A20:CZ47)

The “NovoEleminaLinhas” and “NovoInserirLinhas” work fine, the problem is “COPIARLINHAS”


REM  *****  BASIC  *****

Sub Main
call NovoEleminaLinhas
call NovoInserirLinhas
call COPIARLINHAS
End Sub

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

Dim xSheet As Variant
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
xSheet= ThisComponent.getCurrentController().getActiveSheet()
        
Dim Valori as integer
Dim Valorf as integer
Valorf=xSheet.getCellByPosition(0,0).value+1
Valori=21
dim DeleteSt as string

DeleteSt= "$A"+Valori+":$A"+Valorf

args1(0).Name = "ToPoint"
args1(0).Value = DeleteSt

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DeleteRows", "", 0, Array())
end sub

sub NovoInserirLinhas
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
xSheet= ThisComponent.getCurrentController().getActiveSheet()
Dim Valori as integer
dim Valorf as integer
Valori=21
Valorf=48
dim InsertSt as string
InsertSt= "$A"+Valori+":$A"+Valorf
args1(0).Name = "ToPoint"
args1(0).Value = InsertSt
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:InsertRows", "", 0, Array())
end sub
rem --=================================================

sub COPIARLINHAS
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")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$cz$20"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
xSheet= ThisComponent.getCurrentController().getActiveSheet()
dim Valor0 as integer
dim Valori as integer
dim Valorf as integer
Valor0=20
Valori=Valor0+1
Valorf=48
dim CopySt as string
CopySt= "$A"+Valor0+":$CZ"+Valor0
args2(0).Name = "ToPoint"
args2(0).Value = CopySt
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args2())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
dim PasteSt as string
PasteSt= "$A"+Valori+":$CZ"+Valorf
args3(0).Name = "ToPoint"
args3(0).Value = PasteSt
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
end sub