python 怎么设置ppt图表区的颜色以及给图表区加上边框

2025-04-18 06:44:07
推荐回答(1个)
回答1:

Python Code:

from win32com.client import GetObject

msoChart = 3
msoTrue = -1

objApp = GetObject(Class = "PowerPoint.Application")
objPre = objApp.ActivePresentation
objSld = objPre.Slides(1)

if objSld.Shapes(1).Type == msoChart:
    # 图表区
    objChart = objSld.Shapes(1).Chart
    objChart.ChartArea.Format.Fill.ForeColor.RGB = 0xFFFF8F0
    
    # 边框
    objLFmt = objChart.Format.Line
    objLFmt.Visible = msoTrue
    objLFmt.ForeColor.RGB = 0x50B000
    objLFmt.Weight = 3

运行前:

运行后: