| View previous topic :: View next topic |
| Author |
Message |
jaykup Newbie

Joined: 09 May 2006 Posts: 2
|
Posted: Mon Apr 02, 2007 12:19 pm Post subject: Split large file into individual pages - uniq file names |
|
|
I have a very large (300+ page) odt document that has the following layout:
| Quote: |
A577 BLACK
Delrin A577 BLACK ACETAL, G-FILLED
Acetal
_________________Virgin
_________________Regrind
Weight:_________________
Verified By:______________
Date Verified:_____________
|
The first three lines change with each page, the rest is the same.
I would like to split this into 300+ files all with the file names corresponding to the unique first line. How can I do this?
os: Windows 2000 / Slackware 10.2 |
|
| Back to top |
|
 |
conficio General User

Joined: 06 Jun 2006 Posts: 16 Location: Melrose, MA USA
|
Posted: Thu Apr 05, 2007 5:52 am Post subject: |
|
|
It won't be an easy thing that you get tools for.
However, the *.odt files are compressed xml files. I'm not sure if you can uncompress them with WinZip and then attack it with n XSLT script.
The other option would be to write a macro, that does this for you.
Are you a programmer? If not, I'd look for someone to do it for you and pay her.
K<o> _________________ Plan-B for OpenOffice.org - Software Help for the Rest of Us!
by Conficio - teaching software one screencast at a time |
|
| Back to top |
|
 |
acknak Moderator


Joined: 13 Aug 2004 Posts: 4295 Location: ~ 40°N,75°W
|
Posted: Thu Apr 05, 2007 11:26 am Post subject: |
|
|
Could I ask why you want to do this? It sounds like something you'll later wish to un-do  |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8982 Location: Lexinton, Kentucky, USA
|
Posted: Fri Apr 06, 2007 6:20 am Post subject: |
|
|
Here's a macro that should do what you want. Because it will overwrite existing files I would suggest that you put your current file in a new directory so there are no other files in that directory to worry about. | Code: | 'Creates one file per page of current file
'with file name = 1st para with text. WARNING, will
'overwrite file with same name without asking.
Option Explicit
Sub ManyFromOne
Dim oDoc,sUrl,fPath,oVC,oTC,fName,s
Dim oNew,oNewVC,oNewTC,oStart,nUrl
oDoc = ThisComponent
sUrl = oDoc.URL
s = Split(sUrl,"/") : s(uBound(s)) = ""
fPath = Join(s,"/")
oVC = oDoc.CurrentController.getViewCursor
oVC.gotoStart(false)
oTC = oDoc.Text.createTextCursor
oNew = StarDesktop.loadComponentFromUrl("private:factory/swriter","_blank",0,Array())
oNewVC = oNew.CurrentController.getViewCursor
Do
oStart = oDoc.Text.createTextCursorByRange(oVC)'The beginning of a page.
oTC.gotoRange(oVC,false)
TryAgain:
While oTC.isEndOfParagraph 'Get the filename from first para. with text.
oTC.gotoNextParagraph(false)
Wend
oTC.gotoEndOfParagraph(true)
fName = Trim(oTC.String)
If Len(fName) = 0 then 'File name was from para. with spaces only.
oTC.collapseToEnd : oTC.gotoNextParagraph(false)
GoTo TryAgain
Else nUrl = fPath & fName & ".odt"
EndIf
oVC.JumpToEndOfPage
oVC.gotoRange(oStart,true)
oNewVC.String = oVC.String
oNewTC = oNew.Text.createTextCursor
While oNewTC.gotoNextParagraph(false) 'Delete line breaks at
oNewTC.goRight(1,true) 'beginning of paras.
IF Asc(oNewTC.String) = 10 then oNewTC.String = ""
Wend
oNew.StoreToURL(nUrl,Array())
oNewVC.String = "" : oVC.collapseToEnd
Loop While oVC.JumpToNextPage
oNew.dispose
End Sub |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|