Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / November 2007

Tip: Looking for answers? Try searching our database.

PPT 2003: How to set background color for text in a textbox?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave Jenkins - 28 Nov 2007 00:16 GMT
Let me see if I can explain this without confusing both of us:

I have vba code that creates a textbox.  When the textbox is created and the
user begins to enter text, the entire text frame turns white, and the text
color is taken from defaults (I guess -- at any rate, it's certainly not the
color I specify in the code when I create the textbox).  If the textbox is
created with some default text in it, the text is displayed (in my test case)
as white on a black background.

As soon as the user quits entering text (by selecting something else, say),
the textframe background/fill reverts to the fill color for the entire
textbox and the text itself changes to the color specified in the code for
text in the shape.

This only happens in PPT 2003 - in 2007 all operations behaves as expected
(or at least as desired) regardless of whether the textbox is created with
defaulted text in it or not.

My question is: in PPT 2003, is there any way to create a textbox with red
fill, say, and specify white text, and have the text appear as white on a red
backgound when the text is being entered?  

Here's some code that I've been using.  I'm sure that for testing purposes
more of it could be deleted, but I haven't started going through that
exercise yet.

Sub TextboxTest()

Dim tBoxSh         As Shape
Dim oTxtRng        As TextRange

' Inserts black-bordered text box with red fill, and sets the font as Ariel
Narrow at 12 pt, with white text.
   
   Set tBoxSh =
ActiveWindow.View.Slide.Shapes.AddTextbox(msoTextOrientationHorizontal,
-16.375, 120.75, 240!, 30!)
       With tBoxSh
   
     ' fill parameters
     .Fill.Visible = msoTrue
     .Fill.Solid
     .Fill.ForeColor.RGB = RGB(255, 0, 0)
     .Fill.Transparency = 0#
     
     ' line parameters
     .Line.Weight = 2#
     .Line.Visible = msoTrue
     .Line.ForeColor.RGB = RGB(0, 0, 0)
 
     With .TextFrame
       .WordWrap = msoTrue
       .AutoSize = ppAutoSizeShapeToFitText
       .MarginBottom = 6
       .MarginLeft = 6
       .MarginRight = 6
       .MarginTop = 6
             
       With .TextRange

' here's where I can populate the textbox with soem default stuff
          .text = "default text"

          With .Font
            .name = "Arial Narrow"
            .Size = 18
            .BaselineOffset = 0
            .Color.RGB = RGB(Red:=255, Green:=255, Blue:=255)

          End With   ' .font
       End With      ' .textrange
     End With        ' .textframe
     
   End With        ' ActiveWindow.Selection.ShapeRange(1)
 
' this code here in an attempt to create an visible iinsertion bar at the
start of text
   Set oTxtRng = tBoxSh.TextFrame.TextRange
   oTxtRng.Characters(oTxtRng.Start + oTxtRng.length, 0).Select
                                               
   Exit Sub
   
End Sub

Signature

Dave Jenkins
K5KX

Dave Jenkins - 28 Nov 2007 02:10 GMT
I have greatly simplified the test code and it can be found below.  I have
also discovered the proximal cause of the weird results I'm getting: they're
caused by the choice of color used for the text.  (Really. See comments in
code under "with .font".)  I can live with that, because all I have to do is
adjust the colors I'll be using and all will be well.  However, I *would*
like to know exactly what's going on -- can someone fill me in?

> Let me see if I can explain this without confusing both of us:
>
[quoted text clipped - 21 lines]
> more of it could be deleted, but I haven't started going through that
> exercise yet.

[snip]

Test code (mind the word wraps):

Sub test()

Dim tBoxSh         As Shape
Dim oTxtRng        As TextRange
 
   Set tBoxSh =
ActiveWindow.View.Slide.Shapes.AddTextbox(msoTextOrientationHorizontal,
-16.375, 120.75, 240!, 30!)
   With tBoxSh
   
     ' fill parameters
     .Fill.Visible = msoTrue
     .Fill.Solid
     .Fill.ForeColor.RGB = RGB(255, 0, 0)
     .Fill.Transparency = 0#
     
 
     With .TextFrame
             
       With .TextRange
          .Text = "abcd"
       
          With .Font

' the RGB values chosen appear to drive the problem (but only in PPT 2003)
' with  a choice of 0, 0, 0 the  problem occurs, as it does with, say, 0, 0,
1.  
' With the values below, the program behaves as desired.

            .Color.RGB = RGB(Red:=100, Green:=100, Blue:=100)

          End With   ' .font
       End With      ' .textrange
     End With        ' .textframe
     
   End With        ' ActiveWindow.Selection.ShapeRange(1)
 
   Set oTxtRng = tBoxSh.TextFrame.TextRange
   oTxtRng.Characters(oTxtRng.Start + oTxtRng.Length, 0).Select
                                               
   Exit Sub
   
End Sub
John Wilson - 28 Nov 2007 08:59 GMT
If I'm reading you right Dave what you need is a "normal" feature in 2003. If
you add the text box manually do you not see exactly the same.

The "highlight" color is supposed to aid legibilty and depends on the text
color / fill color and background color (in a complex way I don't understand)
The sample that works has hit on a grey that doesn't change the highlight
color.

As far as I can tell greys don't usually change the highlight unless PPT
thinks they are near white / near black. Try 235,235,235 as your RGB that's
pretty close to white but I think still grey to PPT.
Signature

Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk

> I have greatly simplified the test code and it can be found below.  I have
> also discovered the proximal cause of the weird results I'm getting: they're
[quoted text clipped - 76 lines]
>    
> End Sub
Robert L - 29 Nov 2007 16:20 GMT
I am trying to modify the backcolor for a text box control on a slide....
Why can I change the text for the control, but I cannot change the forecolor
or backcolor?
Signature

Robert L

> Let me see if I can explain this without confusing both of us:
>
[quoted text clipped - 79 lines]
>    
> End Sub
Steve Rindsberg - 29 Nov 2007 21:11 GMT
> I am trying to modify the backcolor for a text box control on a slide....
> Why can I change the text for the control, but I cannot change the forecolor
> or backcolor?

OLEControls don't have the same properties as PPT shapes.
Rightclick the control, choose Properties ... you can set the background and
foreground colors there.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.