我的插件提供了一个颜色选择器供用户选择一些颜色。我想知道如何将这些选定的颜色保存为PowerPoint中的主题(我可以稍后加载)。
答案 0 :(得分:1)
这应该让您开始修改/创建/保存/加载主题。
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