[Issue] Save as first sentence

Discuss the word processor
Post Reply
markschu
Posts: 1
Joined: Tue Jan 22, 2008 3:33 pm

[Issue] Save as first sentence

Post by markschu »

When I save a document I would like the first sentence (or the heading) to be the name of the document, (without re-typing it). Does anyone know if this is possible and how to do it?
Last edited by Hagar Delest on Wed May 13, 2009 2:51 pm, edited 1 time in total.
Reason: tagged the thread as Issue (link to a bug report).
Bill
Volunteer
Posts: 8934
Joined: Sat Nov 24, 2007 6:48 am

Re: save as first sentence

Post by Bill »

You can register and vote for the enhancement:

Issue 14077: There is not a default name for save a doc (writer)
Dave
Posts: 1011
Joined: Sun Dec 23, 2007 6:53 pm

Re: save as first sentence

Post by Dave »

markschu wrote:When I save a document I would like the first sentence (or the heading) to be the name of the document, (without re-typing it). Does anyone know if this is possible and how to do it?
I thought this had been sent. Apologies if it is a repeat.

Solution: Copy/paste.

I personally find that "feature" to be useless and intrusive. The first sentence is not always how I would want to also describe my file. In fact, it's probably never.

David.
JohnV
Volunteer
Posts: 1585
Joined: Mon Oct 08, 2007 1:32 am
Location: Kentucky, USA

Re: save as first sentence

Post by JohnV »

 Edit: Hagar (Moderator): updated macro: [Writer] Save with first line as file name. 
Here is a starter macro.

Code: Select all

 Sub SaveAsFirstSentence
    On Error goto ErrorHandler
    Dim oDoc,oTC,s,w, iAns
    oDoc = ThisComponent
    oTC = oDoc.Text.createTextCursor
    While oTC.isEndOfParagraph 'Find first text.
    oTC.gotoNextParagraph(false)
    Wend
    oTC.gotoEndOfSentence(True)'Get sentence or title
    s = oTC.String
    s = Trim(s) 'Delete leading and trailing spaces.
    While Asc(s) = 9 'Delete leading tabs.
    s = Right(s,Len(s)-1)
    Wend
    If Right(s,1) = "." then s = Left(s,Len(s)-1)'Delete trailing period.
    GlobalScope.BasicLibraries.LoadLibrary("Tools")'Get OOo default directory.
    w = GetPathSettings("Work")
    w = ConvertToUrl(w & "/" & s & ".odt")'Create URL string.
    If FileExists(w) then
     iAns = MsgBox("File already exists. Overwrite it?",4)
     If iAns = 7 then End
    EndIf 
    oDoc.StoreAsUrl(w,Array())'Same as Save As.
    End
    ErrorHandler:
    MsgBox "Check for illegal file name characters in:" & Chr(13) & s
    End Sub
prr
Posts: 235
Joined: Wed Feb 04, 2009 5:37 pm

Re: [Issue] Save as first sentence

Post by prr »

John, I've been using your macro now--works fine most of the time. Installed it on my File menu, so its right where it should be.

I do have one question. When I type in a character that Windows doesn't like to save in the title, like a colon, I get an error message, then I have to take out the colon.

Is there a simple snippet that could be inserted, that would have the macro ignore any of these non-allowed non-alphanumeric characters?
LO 7.1.6.2 on Windows 10
Post Reply