Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How can I add formatted text to a cell?

I have some VB code that places formatted text strings in cells. The formats
consist of color as well as italics and underlining. I apply the formatting
using an "objcell.characters(intStart, intLength).Font.Italic" type of
approach. Where I am having trouble is when I want to add more text to the
cell later. The formats seem to shift or change. What might have been
previously not underlined is now underlined for example. The colors tend to
work properly but the italic, bold, or underline settings have been unstable.
For example, the existing string might have been italic and I try to add
plain text to it without affecting the italic stuff. The result might be
either all italic or all plain.

I modify the strings using the formula property and perhaps that is the
problem but I can't seem to think of another way to add text. Should I be
using a different method to build the strings? It really is frustrating
because this should have been the easy part of the code I wrote and it is
killing me. Has anyone else written code that does something similar?

I am sure feeling like an idiot banging my head up against this issue.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default How can I add formatted text to a cell?

Hi ScabHead
Have you tried following approach to insert data

Range("A1").Characters(Start:=8,Length:=1).Insert "Y"
This replaces the 8th character

Range("A1").Characters(Start:=8,Length:=0).Insert "Y"
This does not replace any character and adds Y in the 8th position

etc

"scabHead" wrote:

I have some VB code that places formatted text strings in cells. The formats
consist of color as well as italics and underlining. I apply the formatting
using an "objcell.characters(intStart, intLength).Font.Italic" type of
approach. Where I am having trouble is when I want to add more text to the
cell later. The formats seem to shift or change. What might have been
previously not underlined is now underlined for example. The colors tend to
work properly but the italic, bold, or underline settings have been unstable.
For example, the existing string might have been italic and I try to add
plain text to it without affecting the italic stuff. The result might be
either all italic or all plain.

I modify the strings using the formula property and perhaps that is the
problem but I can't seem to think of another way to add text. Should I be
using a different method to build the strings? It really is frustrating
because this should have been the easy part of the code I wrote and it is
killing me. Has anyone else written code that does something similar?

I am sure feeling like an idiot banging my head up against this issue.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
tabsheet-function to get the formatted text of a cell Norbert Winkler Excel Discussion (Misc queries) 2 July 29th 11 06:05 PM
A lot of #'s in my text-formatted cell... DeeDeeCee Excel Discussion (Misc queries) 2 November 2nd 08 12:12 PM
Formula fails in text formatted cell kennoc Excel Worksheet Functions 2 May 3rd 06 12:36 AM
Formatted Cell Changes Format When Text Is Entered SundanceKidLudwig Setting up and Configuration of Excel 3 September 30th 05 09:21 PM
Converting 'General' formatted cells to Text formatted cell using. Zahid Khan Excel Worksheet Functions 1 March 12th 05 07:13 PM


All times are GMT +1. The time now is 11:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"