Как создать желтое текстовое поле? - PullRequest
0 голосов
/ 15 января 2019

Как создать желтое текстовое поле?

Я попробовал ниже, но я не могу сделать это так, чтобы а) делает это на активном слайде, б) это сделано желтым (возможно с некоторым форматированием как тень) спасибо

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

1 Ответ

0 голосов
/ 15 января 2019

Использование ActiveWindow.Selection.SlideRange (1) вместо ActivePresentation.Slides (1) обычно дает необходимую вам ссылку на слайд.

Попробуйте для начала:

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 
...