OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Getting the document filename

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
gumbygo
Newbie
Newbie


Joined: 06 Jun 2006
Posts: 1

PostPosted: Tue Jun 06, 2006 3:43 pm    Post subject: Getting the document filename Reply with quote

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
View user's profile Send private message
noranthon
Super User
Super User


Joined: 07 Jul 2005
Posts: 3318

PostPosted: Tue Jun 06, 2006 5:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
uros
Super User
Super User


Joined: 22 May 2003
Posts: 601
Location: Slovenia

PostPosted: Tue Jun 06, 2006 9:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group