Answered by:
Cannot change colors in a PPT color scheme

Question
-
I am using VSTO 2010(SP1) runtime and PowerPoint 2007(SP2).
I have some relatively simple code - I want to create a new custom color scheme.
ColorScheme myScheme = Globals.ThisAddIn.Application.ActivePresentation.ColorSchemes.Add();
myScheme[PpColorSchemeIndex.ppBackground].RGB = 0xFF0000;
myScheme[PpColorSchemeIndex.ppForeground].RGB = 0x00FF00;
myScheme[PpColorSchemeIndex.ppFill].RGB = 0x0000FF;The new color scheme is created and initialized as expected (inherits color settings).
None of the color changes happen - no errors are generated, but the set operations are simply ignored and the color values remain unchanged. Is this a known problem and, is there a workaround for it ?
- Edited by kelleymike Friday, November 11, 2011 7:46 AM
Friday, November 11, 2011 7:34 AM
Answers
-
Hi kelleymike,
Thanks for posting in the MSDN Forum.
This is my snippet, it works. It seems you do incorrect process to set you color scheme of your presentation.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Tools.Ribbon; using PowerPoint = Microsoft.Office.Interop.PowerPoint; using System.Windows.Forms; namespace PowerPointAddIn1 { public partial class Ribbon1 { private void Ribbon1_Load(object sender, RibbonUIEventArgs e) { } private void button1_Click(object sender, RibbonControlEventArgs e) { try { PowerPoint.ColorScheme myScheme = Globals.ThisAddIn.Application.ActiveWindow.View.Slide.ColorScheme; myScheme[PowerPoint.PpColorSchemeIndex.ppBackground].RGB = 0xFF0000; myScheme[PowerPoint.PpColorSchemeIndex.ppForeground].RGB = 0x00FF00; myScheme[PowerPoint.PpColorSchemeIndex.ppFill].RGB = 0x0000FF; Globals.ThisAddIn.Application.ActivePresentation.ColorSchemes.Add(myScheme); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception-1"); } } } }
I hope it can help you.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by Casting Ice Sculpture Tuesday, November 15, 2011 3:00 AM
- Marked as answer by 许阳(无锡) Friday, November 25, 2011 6:55 AM
Tuesday, November 15, 2011 2:59 AM
All replies
-
Hello,
Are you saying that using e.g. mySlide.ColorScheme = myScheme doesn't work?
Regards from Belarus (GMT + 2),
Andrei Smolin
Add-in Express Team LeaderFriday, November 11, 2011 8:15 AM -
No - when I add a color scheme to the active presentation, the add is successful.
The problem is that I should be able to set the colors on the newly created scheme and it does not work.
Setting the slide scheme to the new scheme works fine - its just that I cannot modify the colors.
Sorry - I should add: I am using .net 3.5 and C# as well.
- Edited by kelleymike Friday, November 11, 2011 9:15 AM
Friday, November 11, 2011 9:00 AM -
Hmm, I've got the same issue in PowerPoint 2010....
Regards from Belarus (GMT + 2),
Andrei Smolin
Add-in Express Team LeaderFriday, November 11, 2011 4:09 PM -
Can anyone from the VSTO team chime in on this ? I have not tried to do this with VBA but there are a lot of Microsoft code samples showing this works.
- Edited by kelleymike Monday, November 14, 2011 6:56 PM
Monday, November 14, 2011 6:55 PM -
Hi kelleymike,
Thanks for posting in the MSDN Forum.
This is my snippet, it works. It seems you do incorrect process to set you color scheme of your presentation.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Office.Tools.Ribbon; using PowerPoint = Microsoft.Office.Interop.PowerPoint; using System.Windows.Forms; namespace PowerPointAddIn1 { public partial class Ribbon1 { private void Ribbon1_Load(object sender, RibbonUIEventArgs e) { } private void button1_Click(object sender, RibbonControlEventArgs e) { try { PowerPoint.ColorScheme myScheme = Globals.ThisAddIn.Application.ActiveWindow.View.Slide.ColorScheme; myScheme[PowerPoint.PpColorSchemeIndex.ppBackground].RGB = 0xFF0000; myScheme[PowerPoint.PpColorSchemeIndex.ppForeground].RGB = 0x00FF00; myScheme[PowerPoint.PpColorSchemeIndex.ppFill].RGB = 0x0000FF; Globals.ThisAddIn.Application.ActivePresentation.ColorSchemes.Add(myScheme); } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception-1"); } } } }
I hope it can help you.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
- Proposed as answer by Casting Ice Sculpture Tuesday, November 15, 2011 3:00 AM
- Marked as answer by 许阳(无锡) Friday, November 25, 2011 6:55 AM
Tuesday, November 15, 2011 2:59 AM