[Solved] Return current pathname without document name

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

[Solved] Return current pathname without document name

Post by grnhorn »

How can the current pathname be returned without the document name as the following does?

MsgBox ThisComponent.getURL

Thanks...
Last edited by grnhorn on Fri Jul 25, 2008 5:35 pm, edited 1 time in total.
OOo 2.4.X on Ms Windows XP
QuazzieEvil
Volunteer
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Return current pathname without document name

Post by QuazzieEvil »

There are various functions the in the Tools library.

Code: Select all

BasicLibraries.loadLibrary("Tools")
path=DirectoryNameoutofPath(ThisComponent.getURL(),"\")
msgbox path
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: Return current pathname without document name

Post by grnhorn »

Thanks QuazzieEvil, but this also returns the filename attached. What I am looking for is the currentpath (current folder or directory) without the filename or.
OOo 2.4.X on Ms Windows XP
JohnV
Volunteer
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: Return current pathname without document name

Post by JohnV »

Reverse the direction of the slash, i.e., "/".
grnhorn
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

[Solved] Return current pathname without document name

Post by grnhorn »

Thanks JohnV, that worked. I had to make one more change adding GlobalScope." Here is the final code.

GlobalScope.BasicLibraries.loadLibrary("Tools")
path=DirectoryNameoutofPath(ThisComponent.getURL(),"/")
msgbox path
OOo 2.4.X on Ms Windows XP
Post Reply