Can't update or remove Start Application Event macro

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Can't update or remove Start Application Event macro

Post by huw »

A long time ago I added a favourites menu, using the code here:
http://wiki.services.openoffice.org/wik ... rites-Menu
So far as I recall, I just followed the instructions linked there.

Now I need to change the paths. I opened up StarOfice Basic Macros and found the macro in My macros > Standard > Module1. It was the only one. I changed the paths but, even after a full reboot of my computer, the menu still uses the old ones, causing an error instead of opening a document.

I deleted the macro entirely, but the menu still appears (and still refers to the old paths), so there must be a second copy somewhere. I have been through every single macro in My Macros and in StarOffice Macros, and also checked there are none attached to individual documents.

I have also un-assigned the macro from the Start Application Event (at StarOffice level, not just document), which now has nothing assigned. Again another full reboot of the computer, and still the old favorites menu appears.

What am I missing?
User avatar
Villeroy
Volunteer
Posts: 31277
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Can't update or remove Start Application Event macro

Post by Villeroy »

Code: Select all

if not bHasAlreadyPopupMenu then
...set up the items ...
endif
end sub
It's all about lazy macro programming. Since bHasAlreadyPopupMenu is true if there is a menu already, the if-block never gets executed. Delete the existing menu before running.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Can't update or remove Start Application Event macro

Post by huw »

Villeroy wrote:Delete the existing menu before running.
How do I do that? Do you mean before running the whole application? Where do I find the menu to delete it?

Thanks for the response Villeroy.
User avatar
Villeroy
Volunteer
Posts: 31277
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Can't update or remove Start Application Event macro

Post by Villeroy »

The menu is inaccessible through Tools>Customize...Tab:Menu? If you don't want to write another macro for removal: The menu must be registered somewhere in your profile.
Sorry, until now I never fiddled around with user's menus and toolbars, so I don't understand all of the code. However, it should handle this case. I can think of something like

Code: Select all

REM ====== YOUR CUSTOMIZATIONS BELOW ======
<constant declarations of menu items>
...
Sub bla...
...
if bHasAlreadyPopupMenu then
       <code to change menu items>
else
       sString = "Favorites"
       oPopupMenu = ImplCreatePopupMenu( sMyPopupMenuCmdId, sString, oMenuBarSettings )
       oPopupMenuContainer = oPopupMenu(3).Value
       <code to add menu items>
endif
end sub
The original code is not supposed to be a working macro.
http://wiki.services.openoffice.org/wiki/API/Samples/StarBasic/Office/Favorites-Menu wrote: License: None - Treat this as sample code, feel free to reuse
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
huw
Volunteer
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

Re: Can't update or remove Start Application Event macro

Post by huw »

Villeroy wrote:The menu is inaccessible through Tools>Customize...Tab:Menu?
I certainly was missing something - that was it, many thanks!
Villeroy wrote:The original code is not supposed to be a working macro.
http://wiki.services.openoffice.org/wiki/API/Samples/StarBasic/Office/Favorites-Menu wrote: License: None - Treat this as sample code, feel free to reuse
Yes, I didn't even expect it to work "as is", but it did, and I use it all the time without problems. I will go and edit the Wiki to included removal instructions ...
Post Reply