Page 1 of 1

Can't update or remove Start Application Event macro

Posted: Mon Mar 03, 2008 3:05 pm
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?

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

Posted: Mon Mar 03, 2008 7:26 pm
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.

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

Posted: Tue Mar 04, 2008 10:38 am
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.

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

Posted: Tue Mar 04, 2008 11:10 am
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

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

Posted: Tue Mar 04, 2008 11:28 am
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 ...