Recorded macros have no effect

I want a shortcut key to toggle a document view between 1 and 2 columns. To that end I have recorded two macros running through the View.Zoom.Zoom Zoom & View Layout dialog setting values for the Column field.

One of these macros was recorded setting for 1 column, the other for 2.

As you can see they are identical.

And have no effect. However the registrymodifications.xcu has this setting

 registrymodifications.xcu:1213: <item oor:path="/org.openoffice.Office.Writer/Layout/ViewLayout"><prop oor:name="Columns" oor:op="fuse"><value>1</value></prop></item>

I look through the current controller view settings and find nothing about Layout at all.

Where is this? How do I access it via script?

 sub column_toggle_2
 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(2) as new com.sun.star.beans.PropertyValue
 args1(0).Name = "Zoom.Value"
 args1(0).Value = 120
 args1(1).Name = "Zoom.ValueSet"
 args1(1).Value = 28703
 args1(2).Name = "Zoom.Type"
 args1(2).Value = 0
 
 dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args1())
 
 
 end sub
 
 
 sub column_toggle_1
 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(2) as new com.sun.star.beans.PropertyValue
 args1(0).Name = "Zoom.Value"
 args1(0).Value = 120
 args1(1).Name = "Zoom.ValueSet"
 args1(1).Value = 28703
 args1(2).Name = "Zoom.Type"
 args1(2).Value = 0
 
 dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args1())

If you don’t want to use the icons at the bottom right of the Writer screen, you could assign a shortcut key to the existing commands.

Click Tools > Customise > Keyboard, under Category, select View and type in the Function search field one of the following three commands of interest, Book Preview, Multiple Pages Preview and Two Pages Preview. You can assign a shortcut key in that pane, see Help. If you hover over the functions, you will see the uno command.

4 Likes

Ah yes. That does the trick nicely enough. Thanks.