Running a File Specific Macro On File Open Event

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
UlfricSX
Posts: 1
Joined: Wed Sep 09, 2020 4:25 am

Running a File Specific Macro On File Open Event

Post by UlfricSX »

Hello!

So I have an OO Basic macro that is attached to a document rather than saved locally, I want the macro to be executed whenever the document is opened but I can only assign local macros to the events instead of the macro attached to the file.

When I send the file to another computer, it still has the macro but it needs to be manually ran which is no fun.

I tried going to tools > macros > OpenOffice Basic and when I select the macro attached to the file and hit "Assign", the events seem to be for the OpenOffice application instead of the file itself, is there a way to assign macros to file specific events so I dont have to configure macros on every single workstation?

I looked through the documentation and other forum posts and could only find answers for local macros instead of file specific macros, sorry if this has already been asked

Thanks in advance!
Windows 10 Pro
OpenOffice 4.1.7
FJCC
Moderator
Posts: 9280
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Running a File Specific Macro On File Open Event

Post by FJCC »

I think if you use the menu Tools -> Customize -> Events you can get to the macros in the document. I cannot test that at the moment but give it a try.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Running a File Specific Macro On File Open Event

Post by RusselB »

Welcome to the Forums.
My knowledge of macros is very limited, but in theory if you have the macro attached to the file, rather than stored locally, and you assign the macro to run upon opening, it would only execute upon opening that file, since the macro wouldn't exist in any other files that you might be opening.
If that seems confusing, then try it this way:
OpenOffice opens -> Looks for macro -> Finds macro -> Executes.
OpenOffice opens -> Looks for macro -> Doesn't find macro -> Does nothing or reports an error.

Please note that the above is not tested, just based on some logical thinking.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
Zizi64
Volunteer
Posts: 11362
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Running a File Specific Macro On File Open Event

Post by Zizi64 »

Please upload your sample file with the embedded macro code here. Then we will able to examine, why it not run.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
JeJe
Volunteer
Posts: 2784
Joined: Wed Mar 09, 2016 2:40 pm

Re: Running a File Specific Macro On File Open Event

Post by JeJe »

In Tools Menu/Customize/Events Tab

At the bottom of the Dialog there's a combobox to select Openoffice or your document. Assign the macro from your document to your chosen event and choose your document from that combobox.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Running a File Specific Macro On File Open Event

Post by Lupp »

Example:
testDocMacrosOnDocEvents.ods
(62.95 KiB) Downloaded 163 times
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply