within a Macro, Change Font of text in an added TextBox of a Slide

G

Guest

I am adding pictures (one picture to one slide) by Macro to a Presentation,
and then inserting a textbox into each slide showing the FileName of each
added picture.
In 2000, how do I specify the Font of the text as I add it, or change the
font immediately after I have added the textbox.
 
D

David M. Marcovitz

Post the code you use to add the textbox. That will make it easier to write
the one line of code that can change the font.
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
G

Guest

Maybe something like this?

Sub addtext()
Dim otext As Shape
Set otext = ActivePresentation.Slides(1).Shapes.AddTextbox _
(Orientation:=msoTextOrientationHorizontal, _
Left:=500, Top:=200, Width:=200, Height:=50)
With otext.TextFrame.TextRange
.Text = "johnnywizz"
.Font.Name = "AvantGarde"
.Font.Size = 12
End With
End Sub
 
G

Guest

Set myDocument = ActivePresentation.Slides(Cnt + 1)
myDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
10, ActivePresentation.PageSetup.SlideHeight - 30, 500,
30).TextFrame.TextRange.Text = _
" " & StrTemp
 
D

David M. Marcovitz

Set myDocument = ActivePresentation.Slides(Cnt + 1)
myDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
10, ActivePresentation.PageSetup.SlideHeight - 30, 500,
30).TextFrame.TextRange.Text = _
" " & StrTemp

Assuming such things as Cnt and StrTemp are set properly, something like
this should work:

Set myDocument = ActivePresentation.Slides(Cnt + 1)
Set myShape = myDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
10, ActivePresentation.PageSetup.SlideHeight - 30, 500, 30)
With myShape.TextFrame.TextRange
.Text = " " & StrTemp
.Font.Name = "Times New Roman"
End With


--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
G

Guest

Thank You, David, just what I needed

David M. Marcovitz said:
Assuming such things as Cnt and StrTemp are set properly, something like
this should work:

Set myDocument = ActivePresentation.Slides(Cnt + 1)
Set myShape = myDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
10, ActivePresentation.PageSetup.SlideHeight - 30, 500, 30)
With myShape.TextFrame.TextRange
.Text = " " & StrTemp
.Font.Name = "Times New Roman"
End With


--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
G

Guest

Having added the text itself, with the font being specified too, as your code
sample, I now wish to specify a fill colour for the text, and also a fill
colour for the added textbox, please.
 
G

Guest

Try adapting the code like this (obviously change the RGB vaues to what you
need)

With myshape.TextFrame.TextRange
..Text = " " & StrTemp
..Font.Name = "Times New Roman"
..Font.Color.RGB = RGB(100, 0, 0)
End With
myshape.Fill.ForeColor.RGB = RGB(255, 100, 100)
 
G

Guest

Thank you, John, just what I needed: I find MS 2000 VBA help files not too
good if I don't really know what I'm looking for !
 
G

Guest

I was puzzled since the .Forecolor alone didn't apparently do anything, but I
stumbled on .Transparency and eventually .Visible, and finally with all three
I had my text in a frame with a coloured fill at last.

With myShape.Fill
.ForeColor.RGB = RGB(255, 255, 255) ' change for color required
.Transparency = 0.5 ' vary from 0.0 (opaque) to 1.0
(Clear).
.Visible = msoTrue

[I had also tried .Backcolor, and found that either one seemed to do what I
wanted, but then noticed that various gradients can also be used, and assume
that these require one or two colours to be specified to work].
 
S

Steve Rindsberg

I was puzzled since the .Forecolor alone didn't apparently do anything, but I
stumbled on .Transparency and eventually .Visible, and finally with all three
I had my text in a frame with a coloured fill at last.

With myShape.Fill
.ForeColor.RGB = RGB(255, 255, 255) ' change for color required
.Transparency = 0.5 ' vary from 0.0 (opaque) to 1.0
(Clear).
.Visible = msoTrue

Unless you actually NEED the fill to be transparent, I'd set transparency to 0.
It's not the right way to lighten or darken a color because:

- The color will change depending on what's behind the shape.
- Transparency doesn't always print properly
- Transparency can slow printing down tremendously.

Of course, if you never intend to print the show, the last two are in the "Who
cares"? dumper. ;-)
[I had also tried .Backcolor, and found that either one seemed to do what I
wanted, but then noticed that various gradients can also be used, and assume
that these require one or two colours to be specified to work].

You're right on top of it. Also if you use patterned fills, the fore/background
colors determine the colors of the pattern and pattern backgrounds.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top