Changing Fonts and other attributes on a printable slide added by

M

Mark

Hi All,

I have been using Dr. David M. Marcovitz chapter 7.9 (Link to his web below)
to generate a certificate via VB. There are a few things I have yet to be
able to get to work. Any help is appreciated (Code below)

1) I would like to change the font’s of the userName in
printableSlide.Shapes(1)
2) I would like to center printableSlide.Shapes(2) and move it down the page
some.
3) I would like to add a boarder around the page, if possible. I have added
images via example he has supplied, but if I add an image representing a
boarder it covers everything else up. Is there a way to have it on the
bottom? Or a better way?
4) I would like to add a 3rd printableSlide.Shapes(3). Doing so now hangs
up PP.
5) I would like to publicly thank Dr. David M. Marcovitz and others for
their time helping others.

Code:
Sub PrintablePage()
Dim printableSlide As Slide
Dim vRight, vWrong, vResults, vTotal
Dim oPicture As Shape
Dim FullPath As String
Dim oSl As Slide

Set printableSlide = _
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
printableSlide.Shapes(1).TextFrame.TextRange.Text = _
"Label Test Program Results For " & userName
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"You got " & numCorrect & " out of " & numCorrect + numIncorrect & "
- " & (numCorrect / (numCorrect + numIncorrect) * 100) & "%"
printableSlide.Shapes(2).TextFrame.TextRange.Font.Size = 26
Set printButton = _
ActivePresentation.Slides(printableSlideNum).Shapes.AddShape _
(msoShapeActionButtonCustom, 300, 400, 150, 50)
printButton.TextFrame.TextRange.Text = "Print Results"
printButton.ActionSettings(ppMouseClick).Action = ppActionRunMacro
printButton.ActionSettings(ppMouseClick).Run = "PrintResults"
ActivePresentation.SlideShowWindow.View.Next
ActivePresentation.Saved = True

FullPath = "C:\My Documents\my Pictures\leftLogo.jpg"
Set oSl = printableSlide

Set oPicture = oSl.Shapes.AddPicture(FileName:=FullPath, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, Top:=200, _
Width:=100, Height:=100)
With oPicture
.ScaleHeight 1, msoTrue
.ScaleWidth 1, msoTrue
End With

Set oPicture = Nothing
Set oSl = Nothing
FullPath = "C:\My Documents\my Pictures\RightLogo.jpg"
Set oSl = printableSlide
Set oPicture = oSl.Shapes.AddPicture(FileName:=FullPath, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=550, Top:=400, _
Width:=100, Height:=100)
With oPicture
.ScaleHeight 1, msoTrue
.ScaleWidth 1, msoTrue
End With

Set oPicture = Nothing
Set oSl = Nothing

End Sub


http://www.loyola.edu/edudept/PowerfulPowerPoint/Chapter7Examples.html
 
D

David Marcovitz

1. It's certainly easier to do the whole line in a different font with
something like:

printableSlide.Shapes(1).TextFrame.TextRange.Font.Size = 42

to change the size or .Font.Name = "Helvetica" (see page 84).

If you want to change just the username, you could do something like (I
haven't tested this so it might need some tweaking)

userNameLength = Len(userName)
With printableSlide.Shapes(1).TextFrame.TextRange
firstLineLength = .Length
.Characters(firstLineLength - userNameLength, userNameLength) _
.Font.Size = 42
End With

2. To move the shape, you can do something like this:

printableSlides.Shapes(2).Top = 250

For centering, do you want to center the whole text box within the slide
(it should start out that way) or center the text within the textbox?
For just the text, something like this:

printableSlides.Shapes(2).TextFrame.TextRange.ParagraphFormat.Alignment
= ppAlignCenter

3. You can put the shape behind the other shapes by changing the zOrder:

printableSlides.Shapes(5).zOrder msoSendToBack

The 5 is the shape number of your border shape. The problem with this is
that moving the order of shapes could mess up your shape numbering. Why
not just give the shape that is the border No Fill.

printableSlides.Shapes(5).Fill.Visible = False

4. The easiest way to do this is to set the slide type to
ppLayoutTwoColumnText instead of ppLayoutText. This will automatically
give you a third shape to play with.

5. You're welcome. I learned a lot of what I know from this group so
anything you learn from me is partly re-packaged advice from many of the
others in this group.

--David


Hi All,

I have been using Dr. David M. Marcovitz chapter 7.9 (Link to his web below)
to generate a certificate via VB. There are a few things I have yet to be
able to get to work. Any help is appreciated (Code below)

1) I would like to change the font’s of the userName in
printableSlide.Shapes(1)
2) I would like to center printableSlide.Shapes(2) and move it down the page
some.
3) I would like to add a boarder around the page, if possible. I have added
images via example he has supplied, but if I add an image representing a
boarder it covers everything else up. Is there a way to have it on the
bottom? Or a better way?
4) I would like to add a 3rd printableSlide.Shapes(3). Doing so now hangs
up PP.
5) I would like to publicly thank Dr. David M. Marcovitz and others for
their time helping others.

Code:
Sub PrintablePage()
Dim printableSlide As Slide
Dim vRight, vWrong, vResults, vTotal
Dim oPicture As Shape
Dim FullPath As String
Dim oSl As Slide

Set printableSlide = _
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
printableSlide.Shapes(1).TextFrame.TextRange.Text = _
"Label Test Program Results For "& userName
printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"You got "& numCorrect& " out of "& numCorrect + numIncorrect& "
- "& (numCorrect / (numCorrect + numIncorrect) * 100)& "%"
printableSlide.Shapes(2).TextFrame.TextRange.Font.Size = 26
Set printButton = _
ActivePresentation.Slides(printableSlideNum).Shapes.AddShape _
(msoShapeActionButtonCustom, 300, 400, 150, 50)
printButton.TextFrame.TextRange.Text = "Print Results"
printButton.ActionSettings(ppMouseClick).Action = ppActionRunMacro
printButton.ActionSettings(ppMouseClick).Run = "PrintResults"
ActivePresentation.SlideShowWindow.View.Next
ActivePresentation.Saved = True

FullPath = "C:\My Documents\my Pictures\leftLogo.jpg"
Set oSl = printableSlide

Set oPicture = oSl.Shapes.AddPicture(FileName:=FullPath, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, Top:=200, _
Width:=100, Height:=100)
With oPicture
.ScaleHeight 1, msoTrue
.ScaleWidth 1, msoTrue
End With

Set oPicture = Nothing
Set oSl = Nothing
FullPath = "C:\My Documents\my Pictures\RightLogo.jpg"
Set oSl = printableSlide
Set oPicture = oSl.Shapes.AddPicture(FileName:=FullPath, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=550, Top:=400, _
Width:=100, Height:=100)
With oPicture
.ScaleHeight 1, msoTrue
.ScaleWidth 1, msoTrue
End With

Set oPicture = Nothing
Set oSl = Nothing

End Sub


http://www.loyola.edu/edudept/PowerfulPowerPoint/Chapter7Examples.html


--
David M. Marcovitz
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
Microsoft PowerPoint MVP
Associate Professor, Loyola University Maryland
 

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