Jump to content
Jewtus

Powerpoint shapes and adding shadow

Recommended Posts

Jewtus

I've setup the following code to build a PPT:

$oPPT = ObjCreate("PowerPoint.Application")
    $oPresentation = $oPPT.Presentations.Open($File)
    If @error Then
        MsgBox(0, "Error", "Error opening Presentation")
        Exit
    EndIf
    $slide=$oPPT.ActiveWindow.View.Slide
    With $slide
        $objObjectiveText=.Shapes.AddTextBox(1,118,88,350,65) ;.AddTextbox(Orientation, Left, Top, Width, Height)
        $objObjectiveText.TextFrame.AutoSize = 0 ;No autosize textbox
        $objObjectiveText.TextFrame.TextRange.Text = "THIS IS A TEST"
        $objObjectiveText.TextFrame.TextRange.Font.Name = "Times New Roman"
        $objObjectiveText.TextFrame.TextRange.font.size = 10
        $objObjectiveText.Line.Visible = -1 ;msoTrue
        $objObjectiveText.Line.ForeColor.RGB = _WinAPI_RGB(0,0,255) ;Red
        $objObjectiveText.Line.Weight = 2
    EndWith

I've been googling like mad trying to figure out how to add a shadow to the text box but everything I try seems to error. I've tried:

Line.Shadow=true

Line.shadow.type=1 (supposed to be the offset diag right)

TextFrame.Shadow=True

BorderStyle.SpecialEffect = 4

TextFrame.TextRange.Line.Shadow = 1

I even tried a few TextFrame2 (basically the same way I was doing it above)

 

Anyone know the VB command to add shadow to a text box?

 

 

Edited by Jewtus

Share this post


Link to post
Share on other sites
water
$objObjectiveText.Shadow.x

where x is any of the properties you can find here: https://msdn.microsoft.com/en-us/library/ff744621(v=office.14).aspx
This is untested as I do not have PP available at the moment.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
JLogan3o13

Something like this (can't recall which version this was for)

x = ActivePresentation.Slides(4).Shapes(1)
Set tr = x.TextFrame2.TextRange
    With tr.Font.Shadow
        .OffsetX = 10
        .OffsetY = 10
        .Size = 1
        .Blur = 4
        .Transparency = 0.5
        .Visible = True
    End With

 

Edit: Too slow :)

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Jewtus

Ya, I saw some things like that, but I wasn't 100% sure how to invoke it. That one specifically puts a shadow on the text, but not the box itself. I did figure it out from some ridiculously obscure forum for doing something similar in word. This is what I came up with and I tested it and it works.

 

Func FormatTextBox($shape)
    $fillRed =_WinAPI_RGB(0,0,255) ;Red
    $fillWhite =_WinAPI_RGB(255,255,255) ;white
    With $shape
        .TextFrame.AutoSize = 0 ;No autosize textbox
        .Fill.Solid
        .Fill.ForeColor.RGB = $fillWhite
        .Shadow.Visible = True
        .Shadow.Transparency = .6
        .TextFrame.TextRange.Text = "THIS IS A TEST"
        .TextFrame.TextRange.Font.Name = "Times New Roman"
        .TextFrame.TextRange.font.size = 10
        .Line.Visible = -1 ;msoTrue
        .Line.ForeColor.RGB = $fillRed
        .Line.Weight = 2
    EndWith
EndFunc

 

Share this post


Link to post
Share on other sites
water

Exactly what I proposed above ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Jewtus

Exactly what I proposed above ;)

​Yup! I didn't realize though that I had to set it to visible or nothing really happened. The stuff I was reading was saying to use shadow.type=4 (some mso variable) to get what I wanted, but when I set it to visible it actually gets the correct shadow type so I just needed to change the transparency to match the rest of my PPT.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×