I am receiving an unexpected error message when attempting to programmatically adjust the beginning and ending angles of the arc shape in PowerPoint.
Example code that produces the error follows. Note that I ran this code with an already-open instance of PowerPoint and with version 305 of pywin32.
import win32com.client as win32 # Import pywin32
ppt = win32.gencache.EnsureDispatch('PowerPoint.Application') # Connect to PowerPoint application
shp = ppt.ActiveWindow.View.Slide.Shapes.AddShape(25, 200, 200, 100, 100) # Create an arc shape
shp.Adjustments.Item(1) = -45 # Try to adjust the starting angle of the arc (the first yellow circle)
This produces the following error message:
shp.Adjustments.Item(1) = -45 # Try to adjust the starting angle of the arc (the first yellow circle)
^
SyntaxError: cannot assign to function call here. Maybe you meant '==' instead of '='?
Based on this documentation, one should be able to adjust the values of Adjustments.Item(1) and .Item(2). I attempted the same task within PowerPoint's native VBA interface and did not run into any trouble. The VBA code follows:
Sub adj()
Dim startAngle As Double, finishAngle As Double
startAngle = InputBox("Select the starting angle (relative to the x-axis, counterclockwise)", "Start Angle")
finishAngle = InputBox("Select the finishing angle (relative to the x-axis, counterclockwise)", "End Angle")
Set aw = Application.ActiveWindow
Set sl = aw.Selection
Set shp = aw.Selection.ShapeRange(1)
With shp
.Adjustments.Item(2) = startAngle
.Adjustments.Item(1) = finishAngle
End With
End Sub
I am receiving an unexpected error message when attempting to programmatically adjust the beginning and ending angles of the arc shape in PowerPoint.
Example code that produces the error follows. Note that I ran this code with an already-open instance of PowerPoint and with version 305 of pywin32.
This produces the following error message:
Based on this documentation, one should be able to adjust the values of
Adjustments.Item(1)
and.Item(2)
. I attempted the same task within PowerPoint's native VBA interface and did not run into any trouble. The VBA code follows: