The below will create an array of the custom colors present in a theme file, then the values can be stored somewhere. A similar approach can be used to add the colors, instead.
Please note that, in order to use it, you will have to:
- change the extension of the presentation to .zip (and click "Yes" at the prompt)
- enter the zipped file and take the file(s)
.zip\ppt\theme
, pasting them somewhere else
- Process them as needed
- Put them back (not your case unless you want to modify the colors or something else)
Sub ListPowerPointCustomCoLorsV2()
Dim sL As Slide: Set sL = ActivePresentation.Slides(1)
Dim xLAppL As Excel.Application: Set xLAppL = GetObject(, "Excel.Application")
Dim wBTrgt As Excel.Workbook: Set wBTrgt = xLAppL.ActiveWorkbook
Dim oXMLFile As Object: Set oXMLFile = CreateObject("Microsoft.XMLDOM")
Dim XMLFileName As String: XMLFileName = xLAppL.GetOpenFilename(Title:="Please choose XML-file with Load Case definitions", FileFilter:="XML Files *.xml (*.xml),")
oXMLFile.Load (XMLFileName)
Dim tHeme_BLock As MSXML2.IXMLDOMElement: Set tHeme_BLock = oXMLFile.SelectSingleNode("a:theme")
Dim tHeme_BLock_CustomCoLors As MSXML2.IXMLDOMElement: Set tHeme_BLock_CustomCoLors = tHeme_BLock.ChildNodes(3)
Dim customCoLor_XmL() As String: ReDim customCoLor_XmL(1 To tHeme_BLock_CustomCoLors.ChildNodes.Length, 1 To 2) 'customCoLor_XmL_XmL.ChildNodes.Length, 1 To 2)
Dim tHeme_ChiLd_Count As Long
For tHeme_ChiLd_Count = 1 To UBound(customCoLor_XmL) 'tHeme_BLock.ChildNodes.Length
Dim tHeme_CurrentCoLor As MSXML2.IXMLDOMElement
Set tHeme_CurrentCoLor = tHeme_BLock_CustomCoLors.ChildNodes(tHeme_ChiLd_Count - 1)
customCoLor_XmL(tHeme_ChiLd_Count, 1) = tHeme_CurrentCoLor.ChildNodes(0).Attributes(0).Text
customCoLor_XmL(tHeme_ChiLd_Count, 2) = tHeme_CurrentCoLor.Attributes(0).Text
Next tHeme_ChiLd_Count
'Do something with array
oXMLFile.Save (XMLFileName)
End Sub
