[Solved] Macro not doing anything

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
rztv8076
Posts: 6
Joined: Mon Jun 24, 2019 9:59 pm

[Solved] Macro not doing anything

Post by rztv8076 »

I have recorded a macro to do Text to Columns procedure. Here is recorded code. When I run the macro - nothing happens and selected cell is still selected. When I perform macro keystrokes, all works fine.
anybody see an error or have an idea?
thanks in advance.

Code: Select all

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

sub Main
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 ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:TextToColumns", "", 0, Array())

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

end sub
Last edited by Hagar Delest on Tue Jun 25, 2019 10:35 pm, edited 1 time in total.
Reason: tagged solved
OpenOffice 6.2.4.2 on Windows 7
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro not doing anything

Post by JeJe »

Works for me... the TextToColumns dialog box pops up - provided there's a valid selection... check the Data/Text to Columns menu entry is not greyed before you run the macro is all I can suggest.

And remove the Rem from before the line
dispatcher.executeDispatch(document, ".uno:TextToColumns", "", 0, Array())
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
rztv8076
Posts: 6
Joined: Mon Jun 24, 2019 9:59 pm

Re: macro not doing anything

Post by rztv8076 »

Still can't get it to run. i've lowered Security>Macro to minimum. Can you think of where else it might be blocked?
Text to Columns works fine when I do it manually, but I have another 3000 plus rows to do. Trying to "Not go insane".
thanks for your help.
RZ
OpenOffice 6.2.4.2 on Windows 7
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro not doing anything

Post by JeJe »

Charlie Young has a suggestion that avoids the macro recorder here:

viewtopic.php?f=9&t=37246
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
rztv8076
Posts: 6
Joined: Mon Jun 24, 2019 9:59 pm

Re: macro not doing anything

Post by rztv8076 »

I see how this works. Still can't get it to run. I've either got a setting wrong or I'm not running macro correctly.
Tools>Macros>Run Macro>(Select proper macro)>Run

See anything wrong with this procedure? I'm on row 9958 with a bunch to go. Lots of ALT-D xx Enter Enter.

thanks for time and consideration.

RZ
OpenOffice 6.2.4.2 on Windows 7
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro not doing anything

Post by JeJe »

You're not converting text to columns one row at a time surely?
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
rztv8076
Posts: 6
Joined: Mon Jun 24, 2019 9:59 pm

Re: macro not doing anything

Post by rztv8076 »

Surely I am. Can't select multiple rows - option greyed out.
OpenOffice 6.2.4.2 on Windows 7
rztv8076
Posts: 6
Joined: Mon Jun 24, 2019 9:59 pm

Re: macro not doing anything

Post by rztv8076 »

OMG - can't select multiple rows but you can select column. Yikes. This works better.
Thanks for shaking my head to see what I was doing.

RZ
OpenOffice 6.2.4.2 on Windows 7
JeJe
Volunteer
Posts: 2779
Joined: Wed Mar 09, 2016 2:40 pm

Re: macro not doing anything

Post by JeJe »

Yeah, you should be able to do it all in one go.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
rztv8076
Posts: 6
Joined: Mon Jun 24, 2019 9:59 pm

Re: macro not doing anything

Post by rztv8076 »

Thanks JeJe. major help.
OpenOffice 6.2.4.2 on Windows 7
Post Reply