简体   繁体   中英

Change the properties of a powerpoint object

I have the following code:

Sub WriteTextBox()

Dim i As Integer
Dim pptcount As Integer

Dim tb As Shape
Dim sld As Slide
Dim pres As Presentation
Dim var1 As String
var1 = InputBox("Vul hier de maand in")
var2 = "Maand: "
var3 = var2 + var1

pptcount = Application.Presentations.Count

For i = 1 To pptcount
    Set pres = Application.Presentations(i)

    Set sld = pres.Slides(1)

    Set tb = sld.Shapes.AddTextbox(msoTextOrientationHorizontal, 600, 50, 100, 50)
    tb.TextFrame.TextRange.Text = var3
    tb.Line.Visible = True


Next
End Sub

Through which I can place a new text shape into my powerpoint file. I also want to change other stuff in the object (like the font size), but when enter:

tb.TextFrame.TextEffect.FontBold = true

I get an error.

Anybody know how I can add extra features to my text box? Also tried to use With and End With statements but then it does not recognize my object:

With tb.TextFrame.TextRange
    .TextEffect.FontBold = true
End With

tb.TextFrame has no TextEffect property . Try this instead:

tb.TextEffect.FontBold = msoTrue

EDIT Above works in PowerPoint 2010.

The following is for PowerPoint 2003:

tb.TextFrame.TextRange.Font.Bold = msoTrue 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM