Reputation: 31
How do you create a yellow text box?
I tried the below but i cannot do it such that a) it does it in the active slide, b) it is done yellow (potentially with some formatting as shadow) thanks
Sub sticky()
Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=100, Top:=100, Width:=200, Height:=50).TextFrame _
.TextRange.Text = "Test Box"
End Sub
Upvotes: 0
Views: 171
Reputation: 14810
Using ActiveWindow.Selection.SlideRange(1) instead of ActivePresentation.Slides(1) will generally give you the slide reference you need.
Try this for starters:
Sub sticky()
' Use object variables for slide and shape
Dim oSl as Slide
Dim oSh as Shape
' Get a reference to the current slide
Set oSl = ActiveWindow.Selection.SlideRange(1)
' Add the shape and get a reference to it:
Set oSh = oSl.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=100, Top:=100, Width:=200, Height:=50)
With oSh
.TextFrame.TextRange.Text = "Test Box"
.Fill.ForeColor.RGB = RGB(255, 255, 0)
' Add any other formatting to the shape here
End With ' oSh ... the shape you added
End Sub
Upvotes: 1