Running a macro without a prompt

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
pitonyak
Volunteer
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Running a macro without a prompt

Post by pitonyak »

I have a Write document that contains a macro. The macro does some work when the document loads and then it closes the document.

It is preferred if the document loaded without prompting the user. I was asked if there is an easy way to set this during a Non OpenOffice install program.

While I was testing the document, I set a specific location to be considered safe and not prompt.

This document will be installed using a process about which I know almost nothing (but I could ask), so I do not know the language. I do know that it is on Windows.

I have never used a "signed document" to prevent asking.

I was asked how to automate setting things so that the document could load without prompting to run the macro. I indicated a few possibilities, but I did not investigate them:

1. Have the user set the document location as safe manually if they did not want to be prompted everytime they loaded the document.

2. I figure that I can probably write a macro to do this, but I know little about setting such things in the configuration.

3. The configuration file can be set programmatically, but that just feels like a dangerous (and wrong) solution.

So, I don't really know if I am better off recommending that this be based on a signed document or based on document location. I tried to sign a document years ago and I was never able to make it work and I did not try it again.... Is this the best solution?
Andrew Pitonyak
http://www.pitonyak.org/oo.php
LO and AOO on Fedora
User avatar
RoryOF
Moderator
Posts: 34611
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Running a macro without a prompt

Post by RoryOF »

I'm beyond the limits of my knowledge with the detail of your query, Andrew, but having thought a little about it over breakfast, I suggest that if a "signed document" will solve the problem any effort you put getting signed documents to work correctly will be of most general use, both to you and the community. Before putting any great effort into investigating the signed document route, one would need to know if the mechanism works correctly. Can anyone confirm that it does? Perhaps a query on the developer mailing list might confirm (or deny) this.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Running a macro without a prompt

Post by B Marcelly »

Hi,
A document containing macros is potentially insecure. That is the reason of the macro security levels and of the different warnings.
Ultimately, the security is the responsibility of the user.

There are 3 ways to manually open a document macro without warning:
  1. Security level set to Low. In other words : no security.
  2. Security level set to Medium, High or Very High and the document is stored in one of the trusted directories (or its subdirectories) which have been previously chosen by the user. The document need not to be signed.
  3. Security level set to Medium or High and the document is not stored in a trusted directory and the document contains macros signed with certificate(s) and the user has previously put the certificate(s) in its list of trusted certificates (by checking an approbation when loading a similar previous document).
    Note that a certificate should not be trusted forever. It may be revoked or become obsolete. It is the responsibility of the user to verify that his list of certificates is still valid, OpenOffice will not check it at document loading.
Another way is to store the macros in an extension.
The extension is installed manually, or with unopkg. Here again, the user is responsible of what he installs on his computer: an extension is a potential hazard, just like an executable.
The document will suppose that the extension is installed, and will call the macros of the extension.
Note : if the macros are used as functions in Calc formulas, this solution will not work because formulas can only use functions located in the Standard library (of the document or of My Macros).
In fact, the correct way of adding functions for Calc is to create an extension containing an Add-in, not Basic macros.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
pitonyak
Volunteer
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Re: Running a macro without a prompt

Post by pitonyak »

A company has a Word document template containing macros. Some software pulls data from test equipment and creates a file. The software then triggers the Word document to be loaded, which causes the macros to run. With Word, there is at least one location where a document can be loaded and run macros without prompting (I am told). The intent is to have their install CD to contain a copy of an OpenOffice variant (AOO or LO) and to install a version of this document containing a macro converted to work with OO (this exists and functions). They then wanted to set the location where they install the document to run macros without prompting so the user need to deal with that every time.

I assume that if there is a trusted cert, then they still need to add that cert.

Prefer to not just set security level to permissive.

If I turn this into an extension (I am able to do that), then the user would probably need to manually install that and then the external software would need to call that macro directly. Might be doable, but requires more work.
Andrew Pitonyak
http://www.pitonyak.org/oo.php
LO and AOO on Fedora
User avatar
RoryOF
Moderator
Posts: 34611
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Running a macro without a prompt

Post by RoryOF »

Perhaps the installation could be automated, perhaps by a command line (batch file?) invocation of the .oxt file; if OpenOffice/LibreOffice is already correctly installed, the file associations should be set for .oxt files to be associated with OO/LibO. One problem might be providing some automatic reply to queries from OO about "OK to install this?".
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Running a macro without a prompt

Post by B Marcelly »

pitonyak wrote:A company has a Word document template containing macros. Some software pulls data from test equipment and creates a file. The software then triggers the Word document to be loaded, which causes the macros to run.
As I explained, the simplest solution is to install an extension and have the document call the macros of the extension. The document does not contain any macro, it may be stored anywhere. Macros of an extension may be run whatever the security settings.
A document event or a button of the document calls the Basic macro of the extension exactly like calling a macro in another library of My Macros.
Another advantage is that you can update your macros by changing the extension; existing documents stay unchanged.
pitonyak wrote:The intent is to have their install CD to contain a copy of an OpenOffice variant (AOO or LO) and to install a version of this document containing a macro converted to work with OO (this exists and functions).
Rather complex, IMHO : the installation must not conflict with an existing AOO and/or LibO. I would rather use an existing AOO/LibO.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
pitonyak
Volunteer
Posts: 186
Joined: Sun Oct 07, 2007 9:13 pm
Location: Columbus, Ohio, USA

Re: Running a macro without a prompt

Post by pitonyak »

Oh, now that is something to look into....

Would be easy to create the extension...
Andrew Pitonyak
http://www.pitonyak.org/oo.php
LO and AOO on Fedora
Post Reply