Path of the opened Base documents

Discuss the database features
Post Reply
rudolfo
Volunteer
Posts: 1488
Joined: Wed Mar 19, 2008 11:34 am
Location: Germany

Path of the opened Base documents

Post by rudolfo »

I am a bit wondering that I haven't found anything on that when searching for "odb path", because I am sure that I am not the first who faces this problem. While working on some forms I made a backup copy of the .odb document in another folder (but with the same filename). This is the cause for some confusion because Base shows sometimes the path (or filesystem location) with the document and sometimes not.

The list of recently opened Documents (with all OOo docs not only database docs) include the path name.
The dropdown box that is shown on the "New Database" Wizard for the second option "Open an existing database file" only shows the filename so I have duplicated entries there:
 Edit: Actually they are not really "duplicated", because they relate to different files, but I can't know which one 
Duplicated Entries in list of files
Duplicated Entries in list of files
open-existing-db.png (6.97 KiB) Viewed 3686 times
Sometimes I simply chose the Open Button below (in the screenshot it is hidden behind the dropdown entries) to navigate to the file, because this way I know I am working with the right one.

A more annoying problem is that I couldn't find an easy way to identify the location of the currently open .odb file. Fortunately OOo is quite stable and I have the documents open for half a day and/or change to another task on my computer. When I come back I look at the title line and ask myself: "It says mysql-on-this-server.odb, it this the file from the backup directory or the one on that I work?"
Writer or Calc have the File -> Properties Menu Item where I can quickly check the location on the file system. But there is nothing similar for Base.

After some hassle I found myself hacking a macro to get this information:

Code: Select all

Sub ShowCurrentBaseDocPath()
  Dim oBaseDoc As Object
  oBaseDoc = ThisComponent
  If HasUnoInterfaces(oBaseDoc, "com.sun.star.frame.XModel") Then
    MsgBox ConvertFromURL(oBaseDoc.getURL())
  EndIf
End Sub


But there must be an easier way to retrieve this information ...
Thanks in advance for any hints.
Rolf.

BTW, I am working on Windows 2000 with OOo 3.1.1.
OpenOffice 3.1.1 (2.4.3 until October 2009) and LibreOffice 3.3.2 on Windows 2000, AOO 3.4.1 on Windows 7
There are several macro languages in OOo, but none of them is called Visual Basic or VB(A)! Please call it OOo Basic, Star Basic or simply Basic.
goodvibes
Posts: 24
Joined: Sun May 09, 2010 2:04 am

Re: Path of the opened Base documents

Post by goodvibes »

oBaseDoc.getURL() does not return anything for my LibreOffice 7.6.4.1
but MRI shows oBaseDoc.Namespace contains
file:///C:/Data/Base/Migor.odb/Obj61/
which I can use by stripping 'Obj61/'.
Open Office 3.3.0 RC10, Windows 7 (64bit)
F3K Total
Volunteer
Posts: 1040
Joined: Fri Dec 16, 2011 8:20 pm

Re: Path of the opened Base documents

Post by F3K Total »

Simple try

Code: Select all

oBaseDoc = thisDatabaseDocument
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
goodvibes
Posts: 24
Joined: Sun May 09, 2010 2:04 am

Re: Path of the opened Base documents

Post by goodvibes »

Hi F3K Total,
That works thanks. :D
Open Office 3.3.0 RC10, Windows 7 (64bit)
Post Reply