| View previous topic :: View next topic |
| Author |
Message |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8995 Location: Lexinton, Kentucky, USA
|
Posted: Tue Jun 23, 2009 7:02 am Post subject: [Writer] Save with first line as file name. |
|
|
As indicated, this macro will save a Writer file using the first line of text in the file as the file name.
| Code: | Sub FirstLineFileName_Writer
On Error goto EH
oDoc = ThisComponent
oVC = oDoc.CurrentController.getViewCursor
Mark = oDoc.Text.CreateTextCursorByRange(oVC)'mark position of view cursor.
oTC = oDoc.Text.CreateTextCursor 'created at the beginning of doc.
While oTC.isEndOfParagraph 'skip empty paragraphs.
oTC.gotoNextParagraph(false)
Wend
oVC.gotoRange(oTC,false) 'a text cursor can't go to the end of a line
oVC.gotoEndOfLine(true) 'so we have to use the view cursor.
filename = oVC.String
oVC.gotoRange(Mark,false) 'return view cursor to original position.
url = ConvertToURL("C:\SomeDirectory\" & filename)'INSERT YOUR DESIRED DIRECTORY PATH.
oDoc.StoreAsURL(url,Array())
End
EH:
MsgBox "You may have illegal file name characters in the first line." & Chr(13)_
& Chr(13) & filename,,"AN ERROR OCCURRED"
End Sub |
Last edited by JohnV on Mon Oct 05, 2009 2:56 pm; edited 1 time in total |
|
| Back to top |
|
 |
Tommy27 OOo Advocate


Joined: 18 Nov 2006 Posts: 300
|
Posted: Thu Jul 02, 2009 1:43 am Post subject: |
|
|
could be useful.
thanks 4 sharin' it |
|
| Back to top |
|
 |
pir OOo Advocate


Joined: 20 May 2009 Posts: 200 Location: France
|
Posted: Thu Jul 02, 2009 2:19 am Post subject: |
|
|
this is relevant to my interests too, thanks _________________ OpenOffice.org, teh best firewall |
|
| Back to top |
|
 |
edovie General User


Joined: 06 Jul 2009 Posts: 28 Location: Brooklyn [NYC], New York
|
Posted: Sun Jul 12, 2009 11:36 am Post subject: |
|
|
Er, how do I use it? I'm not code-savvy. But it's a feature I'd love. How to do? _________________ ~David Eisner~
Windows XP
Mozilla Firefox 3.5.4
OpenOffice.org 3.1.1 |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8995 Location: Lexinton, Kentucky, USA
|
|
| Back to top |
|
 |
edovie General User


Joined: 06 Jul 2009 Posts: 28 Location: Brooklyn [NYC], New York
|
Posted: Mon Jul 13, 2009 3:47 pm Post subject: |
|
|
Hi John.
I did according to the other thread an apparently it worked. However, I can't find the documents! _________________ ~David Eisner~
Windows XP
Mozilla Firefox 3.5.4
OpenOffice.org 3.1.1 |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8995 Location: Lexinton, Kentucky, USA
|
Posted: Tue Jul 14, 2009 5:56 am Post subject: |
|
|
| Quote: | | I did according to the other thread an apparently it worked. However, I can't find the documents! | What documents? |
|
| Back to top |
|
 |
edovie General User


Joined: 06 Jul 2009 Posts: 28 Location: Brooklyn [NYC], New York
|
Posted: Tue Jul 14, 2009 2:45 pm Post subject: |
|
|
| JohnV wrote: | | Quote: | | I did according to the other thread an apparently it worked. However, I can't find the documents! | What documents? |
Some random documents of no meaning. But they're not in My Documents or Desktop. _________________ ~David Eisner~
Windows XP
Mozilla Firefox 3.5.4
OpenOffice.org 3.1.1 |
|
| Back to top |
|
 |
uros Super User


Joined: 22 May 2003 Posts: 601 Location: Slovenia
|
Posted: Wed Jul 15, 2009 1:55 am Post subject: |
|
|
| edovie wrote: | | But they're not in My Documents or Desktop. |
This program originaly saves your file to the root of disk C:
| Code: | | url = ConvertToURL("C:\" & filename)'Insert Your Desired Directory Path. |
Follow the instruction in a code an insert your path...
For instance
| Code: | | url = ConvertToURL("C:\user\My documents\Reports\" & filename) |
Uros |
|
| Back to top |
|
 |
|