| View previous topic :: View next topic |
| Author |
Message |
gumbygo Newbie

Joined: 06 Jun 2006 Posts: 1
|
Posted: Tue Jun 06, 2006 3:43 pm Post subject: Getting the document filename |
|
|
I'm using OOo on Linux and I want to write some simple BASIC macros to perform RCS checkin/checkout using the ci/co unix commands.
I'd like it to checkin / checkout the currently open document file, but I can't figure out how to retrieve the file name for the current file.
I've tried ThisComponent.DocumentInfo.getPropertyValue(), but none of the properties seem to tell me the file name. What method could get the filename, or something that I can use to construct the file name?
Thanks! |
|
| Back to top |
|
 |
noranthon Super User

Joined: 07 Jul 2005 Posts: 3318
|
Posted: Tue Jun 06, 2006 5:05 pm Post subject: |
|
|
The properties Url and Location each get the full filename, including the path. You could then use the method InStr (which gets you a number corresponding to the number you get with FIND or SEARCH in Calc) combined with MID or RIGHT.
For example: | Code: | sUrl = ThisComponent.Url 'file:///home/terry/Work/Test.ods
sNum = InStr( sUrl, "/work" ) '19
Print MID( sUrl, sNum + 6, 100 ) 'Test.ods
Print RIGHT( sUrl, LEN( sUrl ) - 5 - sNum ) 'Test.ods |
_________________ search forum by month |
|
| Back to top |
|
 |
uros Super User


Joined: 22 May 2003 Posts: 601 Location: Slovenia
|
Posted: Tue Jun 06, 2006 9:34 pm Post subject: |
|
|
Hi gumbygo!
There are four functions in Tools library related to your question.
| Code: | Sub FileNameFromUrl
If Not BasicLibraries.isLibraryLoaded("Tools") then
BasicLibraries.loadLibrary("Tools")
Endif
sDocUrl = ThisComponent.URL
sDocPath = DirectoryNameoutofPath(sDocUrl, "/")
sDocFileName = FileNameoutofPath(sDocUrl, "/")
sDocFileNameExtension = GetFileNameExtension(sDocUrl)
sDocFileNameWithoutExtension = GetFileNameWithoutExtension(sDocUrl, "/")
End Sub |
Hope it helps!
Uros |
|
| Back to top |
|
 |
|