Can't update or remove Start Application Event macro

Creating a macro - Writing a Script - Using the API

Can't update or remove Start Application Event macro

Postby huw » Mon Mar 03, 2008 3:05 pm

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?
huw
Volunteer
 
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

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

Postby Villeroy » Mon Mar 03, 2008 7:26 pm

Code: Select all   Expand viewCollapse view
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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25750
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Postby huw » Tue Mar 04, 2008 10:38 am

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.
huw
Volunteer
 
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm

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

Postby Villeroy » Tue Mar 04, 2008 11:10 am

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   Expand viewCollapse view
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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25750
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Postby huw » Tue Mar 04, 2008 11:28 am

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 ...
huw
Volunteer
 
Posts: 417
Joined: Wed Nov 21, 2007 1:57 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests