如何在powerpoint中以编程方式保存主题颜色

本文关键字:保存 方式 颜色 编程 powerpoint | 更新日期: 2023-09-27 18:09:22

My Add-In提供了一个颜色选择器供用户选择一些颜色。我想知道如何将这些选定的颜色保存为PowerPoint中的主题(我可以稍后加载)

如何在powerpoint中以编程方式保存主题颜色

这应该让你开始修改/创建/保存/加载主题。

Sub FiddleTheThemeColors()
    Dim x As Long
    ' Each slide can have its own color theme;
    ' We'll work with the theme for slide 1
    With ActivePresentation.Slides(1)
        ' First display its rgb values
        ' For your purposes, you'd want to save these somehow
        For x = 1 To .ThemeColorScheme.Count
            Debug.Print .ThemeColorScheme(x).RGB
        Next
        ' Then change the theme
        ' In your case, to whatever values you've saved
        ' But for demonstration purposes, a series of shades of gray
        For x = 1 To .ThemeColorScheme.Count
            .ThemeColorScheme(x).RGB = RGB(x * 20, x * 20, x * 20)
        Next
        ' The .ThemeColorScheme object has .Save and .Load methods
        ' that might work for you ... this will save the theme:
        .ThemeColorScheme.Save "C:'Temp'GrayTheme.thmx"
        ' see below for an example of loading the saved theme
    End With
End Sub
Sub LoadColorScheme()
    With ActivePresentation.Slides(1)
        .ThemeColorScheme.Load "C:'Temp'GrayTheme.thmx"
    End With
End Sub