[Solved] Changing the folder where my macros are stored

Keyboard macros or custom scripts

[Solved] Changing the folder where my macros are stored

Postby RrnR » Tue Jan 14, 2014 10:31 pm

I have a macro in my macros.standard.Module1 and it seems to get stored in my profiles's application data -i.e. C:\Documents and Settings\Me\Application Data\OpenOffice\4\user\basic\standard. Is there any way I can have those scripts stored in another folder (I'm thinking the ALLUSERSPROFILE folder).

This would simplfy synchronizing them to other PC's.

See the bottom of this thread for my solution.
Last edited by RrnR on Thu Jan 16, 2014 10:36 pm, edited 2 times in total.
OpenOffice 4.0.0 on Windows XP SP3
RrnR
 
Posts: 11
Joined: Mon Oct 14, 2013 9:57 pm

Re: Changing the folder where my macros are stored

Postby JohnV » Tue Jan 14, 2014 11:11 pm

If you store the macro in the file then it will go with the file. Otherwise you can open the macro in the Basic IDE, click the Save Basic icon (sheet of paper with a floppy disc) and save it in any directory you choose. Note that there is also a Load Basic Source icon (sheet of paper with a plus sign) so if you take your save directory to another computer you can use that icon to retrieve any saved macro.
JohnV
Volunteer
 
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: Changing the folder where my macros are stored

Postby RrnR » Tue Jan 14, 2014 11:46 pm

Thanks for replying John.

OK, if I save it in any directory I choose, will it get updated in that location if I should later edit the macro? I probably need to explain the scenario in a bit more detail:

I work from two places. My basic folder structure on both PC's is the same C:\My Projects.... I have a regular backup which syncs these two machines in both directions, but it can only work if the files I want to sync live in the same location on each machine. For the folders under C:\My Projects this works, but for historic reasons the folder C:\Documents and Settings\<user name>\Application Data\ is not the same on each PC (different user name). I want to keep the macros in C:\Documents and Settings\All Users\Application Data\.. which will be the same on both machines, and thus will be easy to include in the sync.
OpenOffice 4.0.0 on Windows XP SP3
RrnR
 
Posts: 11
Joined: Mon Oct 14, 2013 9:57 pm

Re: Changing the folder where my macros are stored

Postby Villeroy » Wed Jan 15, 2014 12:00 am

The ALL_USER_PROFILE folder as you name it is the installation directory/share/basic/ where you find all the Basic libraries that are shipped together with OpenOffice and which appear under "OpenOffice Macros" in the macro organizer.
These macros share the same name space with "My Macros". This means that you can not add another "Standard" library under "OpenOffice Macros" and you can not add another "Tools" library under "My Macros".
Under any decent operating system, the installation directory is read-only for regular users.
For any serious macro language orther than StarBasic you simply drop the source code under <install_dir>/share/Scripts/<language_name>/ with admin privileges.

For the ugly Basic lingo you may proceed like this:
Develop in your "My Macros" directory until you are ready to distribute finished code. Do NOT use the "Standard" library for development. Use any descriptive library name for your project or just a component name such as "Calc" because you can not have another Standard library in the same name space.
Tools>Macros>Organize>Basic... [Organizer...], tab [Libraries], [Export...], choose "Export Extension" and save a zipped extension package under some file name.
Get a command line, go to <install_dir>/program/ and call
Code: Select all   Expand viewCollapse view
unopkg.exe add --shared <path_to_your_Basic_extension>

Now you and all the users of the same office installation find your Basic library in the GUI under "OpenOffice Macros" among the Basic libraries that are shipped with OpenOffice itself.

Another way to install arbitrary Basic libraries may work like this:
Copy the library folder to the <install_dir>/share/basic/ folder.
Edit the script.xlc file which is simple XML. Add another entry just like the other ones pointing to your library.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28371
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Changing the folder where my macros are stored

Postby RrnR » Thu Jan 16, 2014 12:06 am

I tried the approach at the end of your last post. Specifically:

I edited the file C:\Documents and Settings\Me\Application Data\OpenOffice\4\user\basic\script.xlc. it contained:

Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:libraries PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">
<library:libraries xmlns:library="http://openoffice.org/2000/library" xmlns:xlink="http://www.w3.org/1999/xlink">
<library:library library:name="Standard" xlink:href="$(USER)/basic/Standard/script.xlb/" xlink:type="simple" library:link="false"/>
</library:libraries>

I added a line:

Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:libraries PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">
<library:libraries xmlns:library="http://openoffice.org/2000/library" xmlns:xlink="http://www.w3.org/1999/xlink">
<library:library library:name="Standard" xlink:href="$(USER)/basic/Standard/script.xlb/" xlink:type="simple" library:link="false"/>
<library:library library:name="My Library" xlink:href="C:/PROJECTS/OpenOffice Libraries/My Library/script.xlb/" xlink:type="simple" library:link="false"/>                <---------- this line added
</library:libraries>

(C:\Projects\... is the folder that is sync'ed to the other machines).

As a start I copied the stuff in the folder $(USER)/basic/Standard/ into the My Library folder. However when I start Writer, I get the error:

OO Error.png
OO Error.png (4.59 KiB) Viewed 11661 times
OpenOffice 4.0.0 on Windows XP SP3
RrnR
 
Posts: 11
Joined: Mon Oct 14, 2013 9:57 pm

Re: Changing the folder where my macros are stored

Postby Villeroy » Thu Jan 16, 2014 12:19 am

C:\Documents and Settings\Me\Application Data\OpenOffice\4\user\basic\script.xlc
is the path where your user profile is saved ("My Macros" in the GUI).
The installation folder is somewhere under C:\Program Files\

The script.xlc looks like this:
Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:libraries PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">
<library:libraries xmlns:library="http://openoffice.org/2000/library" xmlns:xlink="http://www.w3.org/1999/xlink">
<library:library library:name="FormWizard" xlink:href="$(INST)/share/basic/FormWizard/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Template" xlink:href="$(INST)/share/basic/Template/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Tools" xlink:href="$(INST)/share/basic/Tools/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Schedule" xlink:href="$(INST)/share/basic/Schedule/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Gimmicks" xlink:href="$(INST)/share/basic/Gimmicks/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="ImportWizard" xlink:href="$(INST)/share/basic/ImportWizard/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Euro" xlink:href="$(INST)/share/basic/Euro/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Depot" xlink:href="$(INST)/share/basic/Depot/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="ScriptBindingLibrary" xlink:href="$(INST)/share/basic/ScriptBindingLibrary/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
</library:libraries>

$(INST) is the place holder for the installation folder. %20 is an encoded space in a valid URL. So you should add:
Code: Select all   Expand viewCollapse view
<library:library library:name="My Library" xlink:href="$(INST)/share/basic/My%20Library/script.xlb/" xlink:type="simple" library:link="false"/>
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28371
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Changing the folder where my macros are stored

Postby RrnR » Thu Jan 16, 2014 12:47 am

OK, that seemed to work. It still presents a problem however, as the OO installation on the other machine I want to sync to is a 64-bit windows machine, so the OO folder is not C:\Program Files\OpenOffice 4\, but C:\Program Files (x86)\OpenOffice 4\ !!, so it won't sync correctly, as the sync operation assumes that a file from one PC needs to end up in the same folder on the other PC.

Is there no way I can have the folder My Macros in another folder - preferably off C:\Documents and Settings\All Users?

Is there are corresponding meta variable like $(USER) but for the "All Users" folder?
OpenOffice 4.0.0 on Windows XP SP3
RrnR
 
Posts: 11
Joined: Mon Oct 14, 2013 9:57 pm

Re: Changing the folder where my macros are stored

Postby Villeroy » Thu Jan 16, 2014 12:59 am

$(USER) corresponds to the individual profile folder of the current user.
Try this with some network drive X:
Code: Select all   Expand viewCollapse view
<library:library library:name="awt" xlink:href="file:///X:/path/My%Library/script.xlb/"xlink:type="simple" library:link="true"/>

There is an administration guide: https://wiki.openoffice.org/wiki/Docume ... tion_Guide
It is possible to distribute OpenOffice to work places with customized settings and pre-installed extensions.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28371
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Changing the folder where my macros are stored

Postby RrnR » Thu Jan 16, 2014 4:31 am

I studied the pages at https://wiki.openoffice.org/wiki/Docume ... _Libraries and then I tried this:

Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>         
<!DOCTYPE library:libraries PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">
<library:libraries xmlns:library="http://openoffice.org/2000/library" xmlns:xlink="http://www.w3.org/1999/xlink">
<library:library library:name="FormWizard" xlink:href="$(INST)/share/basic/FormWizard/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Template" xlink:href="$(INST)/share/basic/Template/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Tools" xlink:href="$(INST)/share/basic/Tools/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Schedule" xlink:href="$(INST)/share/basic/Schedule/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Gimmicks" xlink:href="$(INST)/share/basic/Gimmicks/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="ImportWizard" xlink:href="$(INST)/share/basic/ImportWizard/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Euro" xlink:href="$(INST)/share/basic/Euro/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="Depot" xlink:href="$(INST)/share/basic/Depot/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="ScriptBindingLibrary" xlink:href="$(INST)/share/basic/ScriptBindingLibrary/script.xlb/" xlink:type="simple" library:link="true" library:readonly="false"/>
<library:library library:name="MyLibrary" xlink:href="file:///C:/Projects/OpenOffice%20Libraries/MyLibrary/script.xlb/"xlink:type="simple" library:link="true" library:readonly="false"/>
</library:libraries>


but I still couldn't get it to work (no error messages, but no macros visible either).
OpenOffice 4.0.0 on Windows XP SP3
RrnR
 
Posts: 11
Joined: Mon Oct 14, 2013 9:57 pm

Re: Changing the folder where my macros are stored

Postby Villeroy » Thu Jan 16, 2014 11:51 am

I tried the same and to my surprise the library appeared under "My Macros" which makes no difference since it is the same name space.
Code: Select all   Expand viewCollapse view
<library:library library:name="File Pickers" xlink:href="file:///mnt/praxis/SERVER/Daten/Install/FilePickers/script.xlb" xlink:type="simple" library:link="true" library:readonly="false"/>
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28371
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Changing the folder where my macros are stored

Postby RrnR » Thu Jan 16, 2014 10:33 pm

After much gnashing of teeth I think I finally have it worked out. The following is the procedure I used:

Lets say for whatever reason you want to store macros you have written in a folder on your PC c:\projects\OpenOfficeLibs\Basic\. In my case the reason was so that my backup system had access to the files.

Create the folder c:\projects\OpenOfficeLibs\Basic\


You now need to edit the file C:\Documents and Settings\<user name>\Application Data\OpenOffice\4\user\basic\script.xlc. The path will differ depending your user name and perhaps on where your OO got installed. On my Windows 8 PC it was in C:\Users\<user name>\AppData\Roaming\OpenOffice\4\user\basic\script.xlc

The file will look something like this:

Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:libraries PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "libraries.dtd">
<library:libraries xmlns:library="http://openoffice.org/2000/library" xmlns:xlink="http://www.w3.org/1999/xlink">
<library:library library:name="Standard" xlink:href="$(USER)/basic/Standard/script.xlb/" xlink:type="simple" library:link="false"/>
</library:libraries>

with your favourite text editor insert the line:

Code: Select all   Expand viewCollapse view
<library:library library:name="Basic" xlink:href="file:///C:/Projects/OpenOfficeLibs/Basic/script.xlb" xlink:type="simple" library:link="true" library:readonly="false"/>

just after the last library:name entry, i.e. just before the closing </library:libraries> tag. Pay careful attention to the number and direction of the path specifiers ("/"). If your path name includes a space you may need to use the characters %20 instead.

Now create a new text file C:/Projects/OpenOfficeLibs/Basic/script.xlb, copy the following text to it and save the file:

Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
<library:library xmlns:library="http://openoffice.org/2000/library" library:name="Basic" library:readonly="false" library:passwordprotected="false">
<library:element library:name="MyModule"/>
</library:library>

Now create a new text file C:\PROJECTS\OpenOfficeLibs\Basic\MyModule.xba and save the following text:

Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="MyModule" script:language="StarBasic">

REM  *****  BASIC  *****

Sub Main
End Sub

Sub Procedure1
End Sub

Sub Procedure2
End Sub

</script:module>

Start OO Writer and inspect Tools/Macros/Organize Macros and you should have a library called Basic under My Macros

NOTE: Under Windows 7 and 8 you may need to start the editor as an administrator to change the files.
OpenOffice 4.0.0 on Windows XP SP3
RrnR
 
Posts: 11
Joined: Mon Oct 14, 2013 9:57 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 6 guests