Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default clear format from RichTextBox

How do I clear the format (font colour only) from a RichTextBox?


When I clear the text (TextRTF) and then put new text in in a different Sub
it works fine, but when I try to do the same in one Sub it doesn't work and
just keep the old format:

Private Sub CommandButton1_Click()
RichTextBox1.TextRTF = "SELECT E.TERM_TEXT FROM ENTRY E WHERE
E.READ_CODE = 'G58..'"
End Sub

Private Sub CommandButton2_Click()
RichTextBox1.TextRTF = vbNullString
End Sub

Private Sub CommandButton3_Click()

Dim strTemp As String

With RichTextBox1
strTemp = .Text
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
.SelColor = 0
.Text = vbNullString
.TextRTF = vbNullString
.TextRTF = strTemp
.Refresh
End With

End Sub


Number 3 doesn't work (although strTemp is a normal string with no
formatting) but number 1 after number 2
works fine.


RBS

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default clear format from RichTextBox


When I ran your 3rd macro on a Richtextbox in one of my forms it removed the
fore colour from the text very well.
Nevertheless maybe all you want is:

Private Sub CommandButton5_Click()
With RichTextBox1
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
.SelColor = RGB(0, 0, 0)
.Refresh
End With
End Sub



- Rm


"RB Smissaert" wrote:

How do I clear the format (font colour only) from a RichTextBox?


When I clear the text (TextRTF) and then put new text in in a different Sub
it works fine, but when I try to do the same in one Sub it doesn't work and
just keep the old format:

Private Sub CommandButton1_Click()
RichTextBox1.TextRTF = "SELECT E.TERM_TEXT FROM ENTRY E WHERE
E.READ_CODE = 'G58..'"
End Sub

Private Sub CommandButton2_Click()
RichTextBox1.TextRTF = vbNullString
End Sub

Private Sub CommandButton3_Click()

Dim strTemp As String

With RichTextBox1
strTemp = .Text
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
.SelColor = 0
.Text = vbNullString
.TextRTF = vbNullString
.TextRTF = strTemp
.Refresh
End With

End Sub


Number 3 doesn't work (although strTemp is a normal string with no
formatting) but number 1 after number 2
works fine.


RBS


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default clear format from RichTextBox

Yes, that does do it indeed.
My mistake was that I was working with a customized RTB that did stop
changes in certain situations.
When I disabled these special properties it worked as expected.

RBS

"Robert Mulroney" '''' wrote in message
...

When I ran your 3rd macro on a Richtextbox in one of my forms it removed
the
fore colour from the text very well.
Nevertheless maybe all you want is:

Private Sub CommandButton5_Click()
With RichTextBox1
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
.SelColor = RGB(0, 0, 0)
.Refresh
End With
End Sub



- Rm


"RB Smissaert" wrote:

How do I clear the format (font colour only) from a RichTextBox?


When I clear the text (TextRTF) and then put new text in in a different
Sub
it works fine, but when I try to do the same in one Sub it doesn't work
and
just keep the old format:

Private Sub CommandButton1_Click()
RichTextBox1.TextRTF = "SELECT E.TERM_TEXT FROM ENTRY E WHERE
E.READ_CODE = 'G58..'"
End Sub

Private Sub CommandButton2_Click()
RichTextBox1.TextRTF = vbNullString
End Sub

Private Sub CommandButton3_Click()

Dim strTemp As String

With RichTextBox1
strTemp = .Text
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
.SelColor = 0
.Text = vbNullString
.TextRTF = vbNullString
.TextRTF = strTemp
.Refresh
End With

End Sub


Number 3 doesn't work (although strTemp is a normal string with no
formatting) but number 1 after number 2
works fine.


RBS



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
richtextbox control can not be created Shasbaz Excel Discussion (Misc queries) 0 November 8th 06 03:06 PM
Using RichTextBox to edit Cell content dlavoie Excel Discussion (Misc queries) 0 October 13th 05 06:13 PM
Clear spreadsheet cells format Souris Excel Programming 2 August 19th 05 11:06 PM
richtextbox Mr M Walker[_2_] Excel Programming 1 July 26th 05 01:36 PM
Install RichTextBox Control Stuart[_21_] Excel Programming 0 April 1st 05 07:18 PM


All times are GMT +1. The time now is 09:58 PM.

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

About Us

"It's about Microsoft Excel"