Page 1 of 1

Launching macros in Writer

PostPosted: Fri Feb 22, 2019 11:04 am
by corto-armitage
Hello everyone,
in Word 2003 I had files I often accessed in a customizable Work menu (you just opened the file clicked on the menu clicked on Add and from then on it was on the menu). Alternatively I pressed Alt-F8 typed a three letter macro name and could launch a macro which opened the file (or did other things of course).

In Libre Writer I can't find any menu similar to the Work one

Also, I tried recording a macro that opens a file but when the file is opened it stops recording and the macro is not saved.

Even if I were to record a macro, opening a macro seems to require going through several submenus, which is time consuming to the point I might as well open the file directly. Isn't there a quicker way to do things? Do I need to associate the macro to a keyboard communication?

Re: launching macros in Writer

PostPosted: Fri Feb 22, 2019 12:01 pm
by corto-armitage
In addition to what I wrote, I've just read online that Libre macros are unable of opening a window (which is depressing considering Word Perfect 5.1, the Dos-based Word-Processor I was using 30 years ago could handle this fine).

So, if that is indeed the case, I would rephrase the above question: in the absence of a macro, any quick way of accessing a file?

Re: launching macros in Writer

PostPosted: Fri Feb 22, 2019 12:12 pm
by robleyd
If it isn't on the recently used list, then I don't know of a quicker method than File | Open in AOO. You could create shortcuts via your operating system; obviously that may become inconvenient with a large number of files.

There is an extension history manager which allows you to increase the number of recent file names stored; my experience with it has been less than desirable.

Re: Launching macros in Writer

PostPosted: Fri Feb 22, 2019 12:41 pm
by corto-armitage
Thx, David. That's disappointing news

Re: Launching macros in Writer

PostPosted: Fri Feb 22, 2019 12:57 pm
by RoryOF
There are some useful macros at http://open-office.es including, if I remember correctly, a macro toolbar that permits speedy access to the installed macros. That site is in Spanish, so you may need to pass sentences through a translator.

Re: Launching macros in Writer

PostPosted: Fri Feb 22, 2019 1:38 pm
by RoryOF
If you can locate a copy of How_to_use_basic_macros.sxw (sxw is an outdated OO format, and can be converted to .odt by earlier OO versions, perhaps Oo 3.x(?)), this is a brief introduction to using macros in OO and includes instructions for linking a macro to a toolbar button.

It does not teach OO BASIC - it assumes you have a working knowledge of that; from memory its screenshots of the builtin macro organiser are from a very early version of OO, but they can be related easily to the current screens.

The master work on OO macros is still that of Andrew Pitonyak.

Re: Launching macros in Writer

PostPosted: Fri Feb 22, 2019 1:51 pm
by JeJe
This macro will open a file. Just change "C:\tmp\footnote test.odt" to the path of your file. It will work in LibreOffice

Code: Select all   Expand viewCollapse view

Sub OpenFile()
dim oDoc,opth as string, args() as  new com.sun.star.beans.PropertyValue
  opth= "C:\tmp\footnote test.odt"
  oDoc = StarDesktop.loadComponentFromURL(convertToURL(opth), "_blank", 0, Args())
End Sub


Edit: corrected to 'as new com.sun.star.beans.PropertyValue'

Re: Launching macros in Writer

PostPosted: Fri Feb 22, 2019 2:07 pm
by JeJe
If you go to Tools/macros/organise macros/LibreOffice Basic/ My Macros/standard module and put the macro there... then
using Tools/customize, you can assign a shortcut or a toolbar item or a menubar item to the macro.

Re: Launching macros in Writer

PostPosted: Fri Feb 22, 2019 8:38 pm
by John_Ha

Re: Launching macros in Writer

PostPosted: Mon Feb 25, 2019 1:36 pm
by corto-armitage
JeJe wrote:This macro will open a file. Just change "C:\tmp\footnote test.odt" to the path of your file. It will work in LibreOffice

Code: Select all   Expand viewCollapse view

Sub OpenFile()
dim oDoc,opth as string, args() as  new com.sun.star.beans.PropertyValue
  opth= "C:\tmp\footnote test.odt"
  oDoc = StarDesktop.loadComponentFromURL(convertToURL(opth), "_blank", 0, Args())
End Sub


Thanks a lot everyone, will try and let you know

Edit: corrected to 'as new com.sun.star.beans.PropertyValue'