Reply
 
Thread Tools Display Modes
  #1   Report Post  
richardC
 
Posts: n/a
Default Changing the format of text in a cell


Hi, can anyone advice how to change the format of a specific bit of text
in a cell, I can set a whole cell to bold like
Dim r As Word.Range
cell = row.Cells(1)
cell.Range.Text = "This is some text"
r = cell.Range
r.Font.Bold = True
but when i try and use
r.SetRange(cell.Range.Start, 4)
to change the word this to bold I dont actually get the right text
In anticipation thanks, for your help
  #2   Report Post  
Jean-Guy Marcil
 
Posts: n/a
Default

richardC was telling us:
richardC nous racontait que :

Hi, can anyone advice how to change the format of a specific bit of
text in a cell, I can set a whole cell to bold like
Dim r As Word.Range
cell = row.Cells(1)
cell.Range.Text = "This is some text"
r = cell.Range
r.Font.Bold = True
but when i try and use
r.SetRange(cell.Range.Start, 4)
to change the word this to bold I dont actually get the right text
In anticipation thanks, for your help


r.Words(1).Font....
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org



  #3   Report Post  
Jay Freedman
 
Posts: n/a
Default

richardC wrote:
Hi, can anyone advice how to change the format of a specific bit of
text in a cell, I can set a whole cell to bold like
Dim r As Word.Range
cell = row.Cells(1)
cell.Range.Text = "This is some text"
r = cell.Range
r.Font.Bold = True
but when i try and use
r.SetRange(cell.Range.Start, 4)
to change the word this to bold I dont actually get the right text
In anticipation thanks, for your help


The second parameter of the SetRange function shouldn't be a length (like
4); it should be the location of the end of the desired range *measured from
the start of the document*. For instance, cell.Range.Start might be 1734,
then the number after the comma would have to be 1738. In code, this would
look like
r.SetRange(cell.Range.Start, cell.Range.Start + 4)

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org


  #4   Report Post  
richardC
 
Posts: n/a
Default

Thanks, that is very helpfull but what I am really trying to do is get a
range object as theremight be mutiple words that i need to change ie a cell
mught have the following text which has been dynamicly assigned
Company full Name
Add1
Add2
PostCode
Tel number
Distance information

I wish to just set theCompany name and distance info to bold hence using a
range obj but the start position does not come back correctlry

"Jean-Guy Marcil" wrote:

richardC was telling us:
richardC nous racontait que :

Hi, can anyone advice how to change the format of a specific bit of
text in a cell, I can set a whole cell to bold like
Dim r As Word.Range
cell = row.Cells(1)
cell.Range.Text = "This is some text"
r = cell.Range
r.Font.Bold = True
but when i try and use
r.SetRange(cell.Range.Start, 4)
to change the word this to bold I dont actually get the right text
In anticipation thanks, for your help


r.Words(1).Font....
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
ISTOO
Word MVP site:
http://www.word.mvps.org




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing 'trace changes' to permanent text color? Alexander Kluge Microsoft Word Help 2 January 21st 05 05:55 PM
changing format in Word for a phrase changes entire document TdyYrLove Microsoft Word Help 1 January 4th 05 12:48 AM
Automatically changing text when another text is changed Melissa S Microsoft Word Help 1 December 29th 04 08:43 PM
Outline Renee Hendershott Page Layout 2 December 25th 04 02:49 PM
Created my own format on first page, want text to continue same. . Wordworrier Microsoft Word Help 1 December 12th 04 08:53 PM


All times are GMT +1. The time now is 07:35 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"