Default Directory for Save As...

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
wsp2
Posts: 8
Joined: Fri Mar 20, 2015 10:51 pm

Default Directory for Save As...

Post by wsp2 »

I have several Writer document templates (ott files) for various projects, and the documents I create using that template are stored in different directories depending on the project. Whenever I open one to create a new document and do a Save As, it uses the directory which was last used. My question is: where does AOO store that directory?

My goal would be to write a batch file or program which switches that directory when I open a template so I don't have to keep navigating to the one I want. I've tried search the registry and the various files in the OO program and user directories, but I've had no luck figuring out where that info is stored.

Similarly, I have the same issue with Export as PDF. I'm hoping that default directory is listed in the same place as the Save As directory.

I'm using AOO 4.0.1 on Windows 7.

Thanks!

Bill
OpenOffice 4.1.1 on Windows
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Default Directory for Save As...

Post by acknak »

[Moved to macro area]

You might try a search here (search box near upper right of each forum page). I know there are macros for saving files, I just don't know if they work exactly as you're after.

I do know this isn't possible without some macro code. You can configure the default document folder, but that's static.
AOO4/LO5 • Linux • Fedora 23
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Default Directory for Save As...

Post by Zizi64 »

Similarly, I have the same issue with Export as PDF. I'm hoping that default directory is listed in the same place as the Save As directory.
Tha AOO stores one URL for the documents and one for the templates. There is not stored different URL-s for the each filetypes - PDF-s, for the spreadsheets or others:
Paths.png
You need create macros (as acknak suggested it) for saving your different type documents into various places.

The real template files (.ott. ots, ...) have not any storing URL-s, when you open them. The normal document files (.odt, .ods) will "remember" its own URL, where you open them from.
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.
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Default Directory for Save As...

Post by RoryOF »

In an extensive research of OO macros (for another purpose), I cannot recollect ever having seen such a file type saving macro.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
wsp2
Posts: 8
Joined: Fri Mar 20, 2015 10:51 pm

Re: Default Directory for Save As...

Post by wsp2 »

Thanks for the replies. I was really hoping this could be done without macros anyway. I thought maybe there was some file or registry entry which contained the path info which AOO uses when doing Save As (or Export PDF). My goal was to write a Python program or something like that which would update the path I wanted in whatever configuration file AOO uses and then open my template.
OpenOffice 4.1.1 on Windows
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Default Directory for Save As...

Post by RoryOF »

Intercept /File /Save As, read the proposed file name. Find and copy the extension; now write the file to a full path into which the extension is incorporated. Of course, one needs to do verifications, such as deciding if the proposed directory exists.

If you start with Andrew Pitonyak's works on OO macro writing
http://www.pitonyak.org/oo.php
I think you will find all the code and API calls you need for doing this in BASIC; of course the pieces will need to be put together.
 Edit: The target directories may be stored in registrymodifications.xcu, but fiddling with this is dangerous and could result in file loss, spellcheck damage, or other horrible things. The best way is to write a dynamic routine that makes an immediate change for the individual file being saved, as I have outlined above.

Having done the above and got the process working to Save files in extension related directories, it should be trivially simple to check the extensions and (say) save all application related extensions together (.ods, .xls etc) or to check the file names and save project related names together. 
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Default Directory for Save As...

Post by Villeroy »

You can install a virtual PDF printer which drops all PDFs into a distinct directory.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
wsp2
Posts: 8
Joined: Fri Mar 20, 2015 10:51 pm

Re: Default Directory for Save As...

Post by wsp2 »

RoryOF wrote:]The target directories may be stored in registrymodifications.xcu, but fiddling with this is dangerous and could result in file loss, spellcheck damage, or other horrible things. The best way is to write a dynamic routine that makes an immediate change for the individual file being saved, as I have outlined above.
I did a quick test on editing the registrymodifications.xcu file. I opened the template and did a Save As to a new directory, then searched the xcu file for that directory name. I found the new directory name listed in a couple of places, so edited it with a new directory name making sure the directory existed, then opened up AOO again. Doing a Save As after the modification still showed the older directory. I think AOO is getting that directory from somewhere else, but I can't figure out where.

I'll give the macro you suggest a shot.
OpenOffice 4.1.1 on Windows
User avatar
RoryOF
Moderator
Posts: 34612
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Default Directory for Save As...

Post by RoryOF »

If one deletes the OO user profile (or simply registrymodifications.xcu), a new user profile (or new registrymodifications.xcu) is rebuilt from default values on next startup. It may be that when the OO profile is being saved, it is built from the default settings and other (historical) information. No one knows. The dynamic method may be best.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply