PDA

View Full Version : Add and format shape



juanbolas
01-23-2022, 11:05 AM
Hello,

This code is supposed to add a shape and format it. However I can't get the height, width, left and top settings to work.


Option Explicit
Sub ExpandWithTables()
Dim oShape As Shape
Dim Guttertotal As Integer
Set oShape = ActiveWindow.Selection.slideRange.Shapes.AddShape(msoShapeRectangle, 100, 100, 100, 100)
Guttertotal = CentimetersToPoints(1#) * 1# * 3
With oShape
.Fill.BackColor.RGB = RGB(210, 210, 210)
.Fill.ForeColor.RGB = RGB(210, 210, 210)
With .TextFrame.textRange
.Text = "[Title goes here]"
With .Font
.Name = "Graphik LCG"
.Size = 18
.Bold = msoTrue
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.color.SchemeColor = ppForeground
.Height = txMainHeight
.Width = txMainWidth / 4 - Guttertotal / 3
.Left = txMainLeft
.Top = txMainTop
End With
End With
End Sub




Public Function CentimetersToPoints(ByVal Centimeters As Double)
CentimetersToPoints = Centimeters * 28.35
End Function




Something similar happens when I try to add and format a table.

Please help me. Thanks in advance