[Issue] Save as first sentence
[Issue] Save as first sentence
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).
Reason: tagged the thread as Issue (link to a bug report).
Re: save as first sentence
You can register and vote for the enhancement:
Issue 14077: There is not a default name for save a doc (writer)
Issue 14077: There is not a default name for save a doc (writer)
Re: save as first sentence
I thought this had been sent. Apologies if it is a repeat.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?
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.
Re: save as first sentence
Edit: Hagar (Moderator): updated macro: [Writer] Save with first line as file name. |
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
Re: [Issue] Save as first sentence
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?
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