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

Is it possible to merge TextRanges?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
sfreeman
General User
General User


Joined: 17 Feb 2009
Posts: 21

PostPosted: Thu May 28, 2009 10:58 pm    Post subject: Is it possible to merge TextRanges? Reply with quote

May i know if it is possible to merge two textRanges into a single one? Thanks in advance
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


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

PostPosted: Fri May 29, 2009 8:05 am    Post subject: Reply with quote

Paragraph one

Paragraph three (paragraph two is blank)

This will merge them.
Code:
Sub Merge
oTC = ThisComponent.Text.CreateTextCursor
oTC.gotoEndOfParagraph(false)'assumes 1st paragraph has text
oTC.gotoEndOfParagraph(true) 'select the text
oTC1 = ThisComponent.Text.CreateTextCursor
oTC1.gotoNextParagraph(false)'assumes 2nd is a blank paragraph.
oTC1.gotoNextParagraph(false)'assumes 3rd has text
oTC1.gotoEndOfParagraph(true)'select the text
oTC.String = oTC.String & " " & oTC1.String 'merge
oTC1.String = "" 'delete paragraph text
oTC1.goLeft(2,true) : oTC1.String = "" 'delete blank paragraphs 
End Sub
Back to top
View user's profile Send private message
sfreeman
General User
General User


Joined: 17 Feb 2009
Posts: 21

PostPosted: Sat May 30, 2009 12:56 am    Post subject: Thanks Reply with quote

Thank you John for your reply, Can we get the textranges defined within a document?
Can we get the index of textRanges defined?
Once again thank you
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


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

PostPosted: Sat May 30, 2009 3:55 pm    Post subject: Reply with quote

If we are talking about Writer then I don't believe there are any "defined" text ranges.
Back to top
View user's profile Send private message
sfreeman
General User
General User


Joined: 17 Feb 2009
Posts: 21

PostPosted: Mon Jun 01, 2009 3:07 am    Post subject: Thank you Reply with quote

Thank you for the information
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 Macros and API 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