a color scheme won't apply (vba)

P

Pat Yearwood

This seems really strange to me. Can someone shed some light on it?

The following macro changes my slide's color sheme. No big deal. I have 5
color schemes in the file. Any index number I put in the code works, EXCEPT
for #3. When set it as #3, it applies scheme #4. Again, all the other
numbers work, but #3. Nothing seems wrong with #3 color scheme itself. I use
it on many slides and can apply it manually just fine.

Here's what I'm using.

Sub ColSch3()
ActiveWindow.Selection.SlideRange.ColorScheme _
= ActivePresentation.ColorSchemes(Index:=3)
End Sub

Any thoughts on this?

TIA,
Pat
 
P

Pat Yearwood

This slight mod works here and if you run it from Normal view rather than
from
w/in the IDE, you can watch what happens at each step. Start there and
let us
know what you discover:

Sub DudeColors()
Dim x As Long
For x = 1 To ActivePresentation.ColorSchemes.Count
MsgBox "About to apply scheme: " & CStr(x)
ActiveWindow.Selection.SlideRange.ColorScheme _
= ActivePresentation.ColorSchemes(Index:=x)
Next ' color scheme
End Sub

Steve, thank you for helping on this. Either I have a corrupt color scheme
mechanism or PowerPoint's scheme numbering system is not as intuitive as it
seems. I would think a scheme's number is what it appears to be by counting
the schemes in the scheme task pane. But my file is not doing that.

I tried replicating this problem in a new file and cannot do it. Maybe,
however, it's because my file is more complicated with many multiple masters
and such. In a new file, the scheme numbering system seems to work right.

In my file, upon the macro applying scheme #3, it applies #4. (I think #4
was edited from #3 at one time.) With the schemes task pane open, I can
clearly see #4 became selected instead of #3. It applies #1 & 2 correctley,
screws up #3, then gets it right again with #4 and on.

To see what would happen, I added more color schemes and reran the macro.
Still, when it came to #3, it got it wrong. In fact, it applied #7 instead
of #3 now. It's difficult for me to peg a trend going on here.

I noticed another oddity while doing this. I deleted schemes 6-8, resaved,
and restarted the file, only to find the macro still applies schemes 6-8.
How is that possible when they no longer exist? In a new file, when I
deleted the schemes, they never would be applied again. What could be
different about my file?

I saved the file as another version, and deleted scheme #3 and it still had
numbering messed up and still applied all the schemes that no longer
existed. I then deleted all but one scheme and it still applied all the
deleted schemes. I then added a second scheme and the macro still did not
see that as the #2 scheme - it saw it as 3 or 4.

Coincidently, I have to rebuild these schemes anyway because our approved
colors changed yesterday, but I can see now this will be a problem. When I
delete the old schemes, the numbering system will be screwed up and deleted
schemes will somehow still exist in a way. The deal is, I have to be able to
apply a scheme through code, but now I don't know how I'll do that when
numbers won't match up to the actual schemes that exist. Grrrrr.

I guess I'll just have to rig it to work. I'll first change the schemes to
the new colors and then see how PowerPoint reacts to numbers I choose to
apply. I'll figure out the pattern it's using and adapt to it. I'll just add
lots of comments in the code to explain the strange numbering system. I
don't know. I'll figure something out, though.

Anyway, if you have any other ideas, I'm all ears. Thanx.
 
P

Pat Yearwood

Steve Rindsberg said:
This slight mod works here and if you run it from Normal view rather than
from
w/in the IDE, you can watch what happens at each step. Start there and
let us
know what you discover:

Hold the phone!

In looking at the master slide view, I now see my multiple masters can
independantly house a unique set of color schemes. So, what is scheme #3 in
one master may not be #3 in another. Although one master only has 2 schemes,
your macro applies the numbered schemes from a some sort of "total" list of
schemes.

I haven't figure this out yet, but this shows me the plot has thickened.
 
P

Pat Yearwood

Steve Rindsberg said:
This slight mod works here and if you run it from Normal view rather than
from
w/in the IDE, you can watch what happens at each step. Start there and
let us
know what you discover:

Ok, in a test version of my file, I basically rebuilt all my schemes from
inside the slide master view, not from normal view. I deleted any unique
schemes a master had different from the others. So all my masters now have
exactly the same choice of schemes.

Now, all the code, including yours, works correctly. Lesson learned (I
think). If I plan to apply color schemes via code from one slide to another
that may involve differing master slides, all my masters have to have the
exact same set of color schemes. That's what it seems to me, anyway.
 
C

clydebrown

Steve Rindsberg said:
Excellent. I was going to suggest looking into this next, but ya beat me
there. I suspect it'd be fairly simple to dupe the schemes from one
master to
the others (in code, though a real nuisance manually).

The time it would take ME to figure out code to dupe the schemes, I would
have already had it done manually. <lmao>

So, I manaully deleted all but one scheme from each master, rebuilt the
schemes I needed, and then deleted the first scheme.

Adding the schemes was not bad because to add a scheme to one master
automatically added it to all masters. However, removing them had to be done
individually from each master. Not fun, but I just got quick on the
accelerator keys and got through it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top