Disable sheet change that macro records

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
skrat
Posts: 19
Joined: Wed Dec 06, 2017 9:47 pm

Disable sheet change that macro records

Post by skrat »

Hi,

I have a button on one sheet, that should copy a certain cell range from another sheet to different cells in that same sheet.

So I recorded a macro, which works, with a small annoying problem: it "blinks" because it also tries to show that the sheet has been changed. Full macro code is here:

Code: Select all

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

sub CopyOnSave
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 = "Nr"
args1(0).Value = 2

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

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "ToPoint"
args2(0).Value = "$A$105:$M$205"

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

rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Flags"
args3(0).Value = "SVDFN"

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

rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ToPoint"
args4(0).Value = "$A$3:$M$103"

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

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

rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "ToPoint"
args6(0).Value = "$A$105"

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

rem ----------------------------------------------------------------------
dim args7(5) as new com.sun.star.beans.PropertyValue
args7(0).Name = "Flags"
args7(0).Value = "V"
args7(1).Name = "FormulaCommand"
args7(1).Value = 0
args7(2).Name = "SkipEmptyCells"
args7(2).Value = false
args7(3).Name = "Transpose"
args7(3).Value = false
args7(4).Name = "AsLink"
args7(4).Value = false
args7(5).Name = "MoveMode"
args7(5).Value = 4

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

rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "Nr"
args8(0).Value = 1

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args8())


end sub
Where I have a strong feeling that

Code: Select all

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

Code: Select all

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, args8())
Are problematic, but as soon as I delete them, it doesn't work well.

So my question is, how can I delete those two lines to avoid showing the sheet change and define (By Name) the sheet where copying should happen?
OpenOffice 4.1.4. Windows 10
John_Ha
Volunteer
Posts: 9584
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: Disable sheet change that macro records

Post by John_Ha »

You might be better searching (and posting) in the Macros and UNO API forum. See Andrew Pitoynak's book on macros.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Post Reply