OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Split a Writer document into one file per page.

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 8979
Location: Lexinton, Kentucky, USA

PostPosted: Thu Mar 31, 2011 9:01 am    Post subject: Split a Writer document into one file per page. Reply with quote

This one gets asked for occasionally.
Code:
Sub OneFilePerPage 'Writer
Dim oDoc,document,dispatcher,oVC,oTC,nDoc,nVC,url,pn
oDoc = ThisComponent
document   = oDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oVC = oDoc.CurrentController.getViewCursor
oVC.gotoStart(false)
url = ConvertToUrl("C:\users\cat\test\page")
nDoc = StarDesktop.loadComponentFromUrl("private:factory/swriter","_blank",0,Array())
nVC = nDoc.CurrentController.getViewCursor
ndocument = nDoc.CurrentController.Frame
Do
pn = pn + 1
oTC = oDoc.Text.createTextCursorByRange(oVC)
oVC.jumpToEndOfPage
oTC.gotoRange(oVC,true)
oVC.gotoRange(oTC,false)
dispatcher.executeDispatch(document,".uno:Copy","",0,Array())
dispatcher.executeDispatch(ndocument,".uno:Paste","",0,Array())
nDoc.storeToURL(url & pn & ".odt",Array())
nVC.gotoStart(true)
nVC.String = ""
Loop While oVC.jumpToNextPage
nDoc.dispose
End Sub
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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