Supercharge your PowerPoint productivity with
|
PPTools |
ProblemYou want to "frame" a slide or slides with a rectangle. SolutionThe FrameASlide subroutine below will add a rectangle of the line thickness you request to a single slide.
Sub CurrentSlide()
' This subroutine calls FrameASlide and passes it
' the current active slide.
Call FrameASlide(ActiveWindow.Selection.SlideRange(1))
End Sub
Sub AllSlides()
' This calls FrameASlide for each slide in the presentation
Dim oSld as Slide
For Each oSld in ActivePresentation.Slides
Call FrameASlide(oSld)
Next
End Sub
Sub FrameASlide(oSld as Slide)
Dim sngLineWidth As Single
Dim oFrameShape As Shape
Dim sngSlideWidth As Single
Dim sngSlideHeight As Single
Dim oSld As Slide
Dim sngOffset As Single
' EDIT:
sngLineWidth = 2 ' frame outline thickness in points
' NO MORE EDITS
sngOffset = sngLineWidth / 2
With ActivePresentation.PageSetup
sngSlideWidth = .SlideWidth
sngSlideHeight = .SlideHeight
End With
With oSld
Set oFrameShape = .Shapes.AddShape(msoShapeRectangle, _
0 + sngOffset, _
0 + sngOffset, _
sngSlideWidth - sngOffset, _
sngSlideHeight - sngOffset)
End With
With oFrameShape
With .Line
.Weight = sngLineWidth
.ForeColor.RGB = RGB(0, 0, 0) ' black
End With
With .Fill
.Visible = msoFalse
End With
End With
End Sub
See How do I use VBA code in PowerPoint? to learn how to use this example code. Español Deutsch Français Português Italiano Nederlands Greek Japanese Korean Chinese |
Supercharge your PPT Productivity with PPTools
|
content authoring & site maintenance by |
Frame a slide with a rectangle
http://www.pptfaq.com/FAQ00941.htm
Last update 12 May, 2008