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

Format part of the text in a cell

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


Joined: 05 Jan 2007
Posts: 16

PostPosted: Fri Feb 03, 2012 6:36 pm    Post subject: Format part of the text in a cell Reply with quote

Cell contains the following text all bolded, but I want to only bold part of the title:

Cell A1 wrote:
My Book Title: My cute subtitle


Unfortunately, I cannot find anything that says how to edit only part of a cell's string.

So I figure loop through each cell get the string. Find the position of the ":" but then I cannot find anything.

I tried recording a Macro but the recorder output did not make any sense.

Code:
For iRow = 1 To numOfRows
     oCell = oSheet.getCellByreference(1,iRow)
     sText = oCell.getValue()
     iPos = instr(sText, ":")
     
     //WHAT GOES HERE?
     
  Next



Appreciate any help/
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Sat Feb 04, 2012 3:17 am    Post subject: Reply with quote

JohnV's macro here any help:

http://www.oooforum.org/forum/viewtopic.phtml?t=123399
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
lknoll
General User
General User


Joined: 19 Oct 2011
Posts: 32
Location: Harrisburg, Pa

PostPosted: Wed Feb 08, 2012 7:26 am    Post subject: Reply with quote

try something like this where you create a cursor within the cell. i had to do something similar with tables, but I needed to format the styles within table cells.

Code:


oDoc = ThisComponent
oVC  = oDoc.CurrentController.getViewCursor()

for i=0 to oDoc.TextTables.Count-1
    oTable = oDoc.TextTables.getByIndex(i)

    for rows=0 to oTable.Rows.Count-1    
        for columns=0 to oTable.Columns.Count-1
            CurrentCell = oTable.getCellByPosition(columns, rows)
            oVC.goToRange(CurrentCell, false)
            sText = oVC.Text.String
            iPos = instr(sText, ":")
        next columns
    next rows
next i

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