Ask Your Question
0

how i display current file name only in open office 2.0 using macro (display on msg box)

asked 2019-03-17 15:45:46 +0100

raj80152 gravatar image

updated 2019-03-25 14:19:24 +0100

how i display current file name in open office 2.0 using macro (display on msg box)

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2019-03-17 17:32:37 +0100

Ratslinger gravatar image

Hello,

sub CurrentFileLocation
    MsgBox ThisComponent.getLocation()
end sub

If this is run on a new unsaved document, the message will be empty. Works on different documents - i.e. Writer, Calc, etc.

edit flag offensive delete link more

Comments

Hi

Just be careful that ThisComponent is indeed a document (do not launch this procedure from a module of the My Maros Standard library, for example)

Regards

pierre-yves samyn gravatar imagepierre-yves samyn ( 2019-03-18 09:12:18 +0100 )edit

i want file name only (without path)

raj80152 gravatar imageraj80152 ( 2019-03-18 15:15:44 +0100 )edit

Since the document name is also in the document frame as a title you can use this:

MsgBox ThisComponent.Title
Ratslinger gravatar imageRatslinger ( 2019-03-18 15:24:52 +0100 )edit

i want file name only (without path)

LibreOffice Macros & DialogTools library▸Strings module includes useful procedures such as FileNameoutofPath, GetFileNameExtension, GetFileNameWithoutExtension, DirectoryNameoutofPath, etc.

You can load & use the library with:

GlobalScope.BasicLibraries.LoadLibrary("Tools")

Regards

pierre-yves samyn gravatar imagepierre-yves samyn ( 2019-03-18 16:53:04 +0100 )edit

@pierre-yves samyn

Thank you. I seldom remember those are there.

Ratslinger gravatar imageRatslinger ( 2019-03-18 17:08:01 +0100 )edit

sub CurrentFileLocation MsgBox ThisComponent.getLocation() end sub

MsgBox ThisComponent.Title

GlobalScope.BasicLibraries.LoadLibrary("Tools")

These are not functioning, i am using open office 2.0

raj80152 gravatar imageraj80152 ( 2019-03-28 02:34:58 +0100 )edit

Unfortunately that was not part of your original question. As this is a LibreOffice forum and that is a very old AOO version, it may be best to post your question on AOO Forum.

Ratslinger gravatar imageRatslinger ( 2019-03-28 04:04:19 +0100 )edit

Hi This is not the right place indeed... However, the procedure as you copied it cannot work (even if the library existed in this version of OOo): instructions appear after the End Sub.

You should write something like:

sub CurrentFileLocation 

GlobalScope.BasicLibraries.LoadLibrary("Tools")
MsgBox FileNameoutofPath(ThisComponent.getLocation())

end sub

Regards

pierre-yves samyn gravatar imagepierre-yves samyn ( 2019-03-28 07:45:46 +0100 )edit

thanks its working.

raj80152 gravatar imageraj80152 ( 2019-03-28 15:32:55 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-03-17 15:45:46 +0100

Seen: 216 times

Last updated: Mar 25