[Solved] Return current pathname without document name

Creating a macro - Writing a Script - Using the API

[Solved] Return current pathname without document name

Postby grnhorn » Fri Jul 25, 2008 1:36 pm

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
grnhorn
 
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: Return current pathname without document name

Postby QuazzieEvil » Fri Jul 25, 2008 3:40 pm

There are various functions the in the Tools library.

Code: Select all   Expand viewCollapse view
BasicLibraries.loadLibrary("Tools")
path=DirectoryNameoutofPath(ThisComponent.getURL(),"\")
msgbox path
QuazzieEvil
Volunteer
 
Posts: 283
Joined: Tue Dec 04, 2007 6:38 pm
Location: Houston, TX

Re: Return current pathname without document name

Postby grnhorn » Fri Jul 25, 2008 4:11 pm

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
grnhorn
 
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm

Re: Return current pathname without document name

Postby JohnV » Fri Jul 25, 2008 5:26 pm

Reverse the direction of the slash, i.e., "/".
JohnV
Volunteer
 
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

[Solved] Return current pathname without document name

Postby grnhorn » Fri Jul 25, 2008 5:35 pm

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
grnhorn
 
Posts: 32
Joined: Sun Jul 13, 2008 2:07 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 10 guests