English
Ask Your Question
1

How do I delete actually opened text file using only LibreOffice options? Or another simple way.

asked 2012-11-02 09:49:11 +0100

Ziutek Kirelejson gravatar image

updated 2013-07-07 22:09:46 +0100

manj_k gravatar image

For example:

1) I found some forgotten text file in some forgotten folder. 2) I opened this file. 3) I saw, that it's unusual file and I want to delete it! I want put it in the Trash folder, but I cannot find this option in LibreOffice.

Now I had to close the document and go to folder, search exactly this file. It takes some time for searching forgotten file in forgotten folder. I want to find an option for deleting of actually opened file.

edit retag flag offensive close merge delete

3 answers

Sort by » oldest newest most voted
0

answered 2012-11-02 10:15:00 +0100

Jean-Baptiste FAURE gravatar image

No, deleting a file is the job of your file manager, not the job of an application software.

edit flag offensive delete link more

Comments

Thank you, your answer was very useful for me. Now I know, that deleting of the files is the job of some file manager, not the job of LibreOffice or another application software. Thanks.

Ziutek Kirelejson ( 2012-11-02 12:06:48 +0100 )edit
1

answered 2012-11-02 11:38:59 +0100

Timon gravatar image

updated 2012-11-02 11:39:23 +0100

If you found some forgotten text file in some forgotten folder, then you used Windows explorer or "Open..." (Ctrl+O) menu item in LibO for that. In both cases you can use popup menu with right mouse button click to delete that file (even to trash folder). What's the problem? -- I want to find an option for deleting of actually opened file. If file is opened, it could not be deleted. First of all you must close file, and only after that you can delete it.

edit flag offensive delete link more

Comments

First of all you must close file, and only after that you can delete it.

Thanks for your answer

Ziutek Kirelejson ( 2013-08-29 20:34:22 +0100 )edit
1

answered 2012-11-02 14:43:45 +0100

cloph gravatar image

Such a functionality will not be added to a standard installation for obvious reasons - the user would be much too likely kill his valuable documents.... But it easy to add that functionality by adding a little Macro.

' closes and deletes the currently active document
' don't use it unless you're OK loosing all your data
' this macro comes with no warrenty whatsoever.
' ALWAYS HAVE A BACKUP
Sub closeAndDelete
    Dim fileurl as String
    Dim answer as Integer
    oDoc = ThisComponent
    If oDoc.hasLocation() Then
        fileurl = oDoc.getLocation()
        If FileExists(fileurl) Then
            answer = msgBox("Do you really want to delete the file"+Chr$(13)+ _
                            "»"+fileurl+"« ?", 4+48+256, "Confirm deletion")
            If answer = 6 Then
                ' user asked for it, so kill it with fire...
                oDoc.close(true)
                Kill(fileurl)
            EndIf
        Else
            msgBox("Error - file "+Chr$(13)+"»"+fileurl+"« does not exist?", 0)
            exit Sub
        EndIf
    Else
        ' document wasn't saved, just close the document
        If oDoc.isModified() Then
            answer = msgBox("Do you really want to throw away your changes?",4+48+256)
            If answer <> 6 Then
                ' abort if answer is not yes
                exit Sub
            EndIf
        EndIf
        oDoc.close(true)
    EndIf
End Sub

To add it, choose Tools | Macros → Organize → LibreOffice Basic and select Module1 below "My Macros" (or create a seperate module if you wish) and choose Edit and copy'n'paste the above macro into the editor and hit the save button.

To assign that macro to a keyboard shortcut, menu entry or toolbar button, go to *Tools | Customize * and select the appropriate section (menu, shortcut or toolbar) to add it. You'll find the Macros at the very bottom in the command/function selection area.

edit flag offensive delete link more

Comments

I have to revise and to merge hundreds of documents (all too often obsolete or redundant) – this macro makes it much easier ... :)

manj_k ( 2012-11-02 20:37:25 +0100 )edit

Very nice. Thanks. Exactly what I want, but I won't use this option because I afraid of risk. But you give very good advice.

Ziutek Kirelejson ( 2012-11-03 20:48:16 +0100 )edit
Login/Signup to Answer

Stats

Asked: 2012-11-02 09:49:11 +0100

Seen: 1,324 times

Last updated: Nov 02 '12