Writting Animation Sequence w/ VBA, problem with line/fill Colorch

C

carbuthn

I am trying to write animation sequences to show flowpaths on a system
drawing for a power plant. Due to the large number of effects 300+ on one
slide, I decided to animate in pieces, write out the parameters to a file,
combine the pieces, and read them back in to the slide. This way I can
modify / correct mistakes. The problem that I am having is writting out the
line / fill color for shape reliably and reading them back in to the right
property. Any help is apreciated. I can download the powerpoint if I can
tell were to put it. About 520k for the one slide.

' I use PrintSequence to write parameters to file but have trouble writting
some of the color
' codes. It only works for a few shapes and animations. Also can not read
them in reliable.

Sub PrintSequence()
Dim objSequence As Sequence
Dim objShape1 As Shape
Dim objShape2 As Shape
Dim objEffect1 As Effect
Dim C As Integer
Dim Color As Long
Dim lngReturn As Long
Dim FileName As String
Dim Direction As Integer

FileName = "C:\temp1\outputfile.txt"
Open FileName For Output As #1
With ActivePresentation.Slides(1)
Set objSequence =
ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Item(1) 'Change
item index to select
'Set objSequence = .TimeLine.MainSequence 'Un-Comment to read main sequence
For C = 1 To objSequence.Count
Set objEffect1 = objSequence.Item(C)
With objEffect1
If .EffectType = msoAnimEffectWipe Then
Direction = .EffectParameters.Direction
Else
Direction = 0
End If
Select Case .EffectType
Case msoAnimEffectChangeLineColor
' If (.Index <> 56) And (.Index <> 58) Then 'index 56 & 58 fault in
sequence 2
Color = .EffectParameters.Color2.RGB
' Else
' Color = 0
' End If
Case msoAnimEffectChangeFillColor
Color = .Shape.Fill.BackColor.RGB
Case Else
Color = 0
End Select
Write #1, .Shape.Name; .Index; .EffectType; .Timing.Duration; Direction; _
.Timing.TriggerType; .Exit; Color; .DisplayName
End With
Next C
End With
Close #1
lngReturn = Shell("NOTEPAD.EXE " & FileName, vbNormalFocus)
End Sub

'I take the output file from above, rename, edit and read it back in to
modify my sequences
' do to the large number of animations on some pages. The presentation is
270+ slides.
' The system supplies makeup water to the reactor and is used in training
new operators.
' may need to change file paths.

Sub ReadSequences()
Dim objSequence As Sequence
Dim objShape1 As Shape
Dim objShape2 As Shape
Dim objEffect1 As Effect
Dim ShapeName As String
Dim Index, EffectType, Speed, Direction, Start, ExitEffect As Integer
Dim Color As Long
With ActivePresentation.Slides(233)
Set objSequence = .TimeLine.InteractiveSequences.Add(1)
Set objShape1 = .Shapes("Normal")
Open "C:\temp1\inputfile.txt" For Input As #1
Do While Not EOF(1)
Input #1, ShapeName, Index, EffectType, Speed, Direction, Start,
ExitEffect, Color
Set objShape2 = .Shapes(ShapeName)
With objSequence
Set objEffect1 = .AddEffect(Shape:=objShape2, _
Effectid:=EffectType, _
Trigger:=Start)
With objEffect1
If EffectType = 22 Then
.EffectParameters.Direction = Direction
End If
If (EffectType <> 54) And (EffectType <> 60) Then
.Exit = ExitEffect
End If
.Timing.Duration = Speed
.Timing.TriggerShape = objShape1
Select Case EffectType
Case msoAnimEffectChangeLineColor
.EffectParameters.Color2 = Color
Case msoAnimEffectChangeFillColor
.Shape.Fill.BackColor.RGB = Color
Case Else
Color = 0
End Select
End With
End With
Loop
End With
Close #1
End Sub
 
C

carbuthn

I am working with shapes, mainly rectangles, arcs, & triangles that make up
symbols for valves.
[]
|>!<| a valve with a rectangle is motor operated, one with an arc (half
circle) is air operated.

An open valve has red lines and white fill. Closed has black lines with
green fill. Throttled has black lines and yellow fill.

The problem is when I have an animation effect that changes the lines from
red to black (msoAnimChangeLineColor) I want to write the new color to the
output file. This allows me to add additional shape and generate a sequence
of effects.

The ReadSequences procedure takes the text file with a line structure =
"Shape Name", Index, EffectType, Speed, Direction, Trigger, ExitProperty,
Color

But I can't find the right color property to read or set. All of the other
properties I can get to work for the most part. It writes the right value
about 80% of the time and read right < 5% of the time.

I have had the procedures work one time then balk at an identical shape with
an error that say can not set color (or something similar). This has only
happened on 2 of 300 effects ( I can handle this by hand if I need to, this
appears to be a bug in copying a shape).

I went to this method after we had a power loss that corrupted my file
during a save. I lost a days worth of work.

Thank you for your help, I can post the presentation if that will help you
to see what I am talking about.
 
C

carbuthn

I deleted most of the shapes from a copy of the slide to make testing easier
with only the one slide in the powerpoint presentation.

The effects that I have left are applied to circles, rectangles, & arcs. I
had added about fifteen animations to the slide. Five were entry wipe
effects in various directions in sequence to show the flowpath through the
pipes. Another 5 changed the line color from red to black. Another 5
changed the fill from white to green.

I added a action button to use as a trigger.

I then ran the print sequence procedure. To write the information to file.
When I compare the colors shown on the file with the ones in the custom
animation panel only some of them matched.

I made corrections to the outputfile i.e. corrected the color values,
renamed to inputfile.txt. I deleted the animations from the slide. Ran
ReadSequence and compared the results to the input file.

I am have not isolated the problem to a given shape but am trying to do that
tonight. I have had copies of the same component (valve) give different
results.

While researching the problem I came across some methods / properties of the
color effect object (By, From, & To) were you enter the desired color
numbers, but have not gotten that to work yet. From the information that I
found this may be the solution, but the information or my understand is
somewhat vague.

Again thanks for your help, I will let you know if I find anything else out,
or solve the problem. By the way I have been using PowerPoint 2002 at the
office, 2003 here at home. I have 2007 but have not tried it in this version.

Steve Rindsberg said:
Thanks for the add'l detail, but again, it'd help to get answers to a few basic
questions:


What's the trouble? You mention that it writes correctly 80% of the time and reads
correctly < 5%. How do you know it's writing correctly if you're not sure what
property to write? How do you know when it's not reading properly? In other
words, have you set breakpoints and stepped through the code, doublechecking values
in the file vs values read/set at each point?



Any pattern to when it happens? Certain values? Certain shapes only?
Is it repeatable? Can you simplify your source PPT to a few shapes that repeatedly
cause the problem?

Error messages? If so, on what line?


I am working with shapes, mainly rectangles, arcs, & triangles that make up
symbols for valves.
[]
|>!<| a valve with a rectangle is motor operated, one with an arc (half
circle) is air operated.

An open valve has red lines and white fill. Closed has black lines with
green fill. Throttled has black lines and yellow fill.

The problem is when I have an animation effect that changes the lines from
red to black (msoAnimChangeLineColor) I want to write the new color to the
output file. This allows me to add additional shape and generate a sequence
of effects.

The ReadSequences procedure takes the text file with a line structure =
"Shape Name", Index, EffectType, Speed, Direction, Trigger, ExitProperty,
Color

But I can't find the right color property to read or set. All of the other
properties I can get to work for the most part. It writes the right value
about 80% of the time and read right < 5% of the time.

I have had the procedures work one time then balk at an identical shape with
an error that say can not set color (or something similar). This has only
happened on 2 of 300 effects ( I can handle this by hand if I need to, this
appears to be a bug in copying a shape).

I went to this method after we had a power loss that corrupted my file
during a save. I lost a days worth of work.

Thank you for your help, I can post the presentation if that will help you
to see what I am talking about.

Steve Rindsberg said:
Thanks for posting the code ... that'll help. But first, tell us exactly what
the problem is. You mention that you're having trouble writing some of the
color codes, but ...

What's the trouble?

Any pattern to when it happens? Certain values? Certain shapes only?

Error messages? If so, on what line?

Is the problem in the write or the read routine?



I am trying to write animation sequences to show flowpaths on a system
drawing for a power plant. Due to the large number of effects 300+ on one
slide, I decided to animate in pieces, write out the parameters to a file,
combine the pieces, and read them back in to the slide. This way I can
modify / correct mistakes. The problem that I am having is writting out the
line / fill color for shape reliably and reading them back in to the right
property. Any help is apreciated. I can download the powerpoint if I can
tell were to put it. About 520k for the one slide.

' I use PrintSequence to write parameters to file but have trouble writting
some of the color
' codes. It only works for a few shapes and animations. Also can not read
them in reliable.

Sub PrintSequence()
Dim objSequence As Sequence
Dim objShape1 As Shape
Dim objShape2 As Shape
Dim objEffect1 As Effect
Dim C As Integer
Dim Color As Long
Dim lngReturn As Long
Dim FileName As String
Dim Direction As Integer

FileName = "C:\temp1\outputfile.txt"
Open FileName For Output As #1
With ActivePresentation.Slides(1)
Set objSequence =
ActivePresentation.Slides(1).TimeLine.InteractiveSequences.Item(1) 'Change
item index to select
'Set objSequence = .TimeLine.MainSequence 'Un-Comment to read main sequence
For C = 1 To objSequence.Count
Set objEffect1 = objSequence.Item(C)
With objEffect1
If .EffectType = msoAnimEffectWipe Then
Direction = .EffectParameters.Direction
Else
Direction = 0
End If
Select Case .EffectType
Case msoAnimEffectChangeLineColor
' If (.Index <> 56) And (.Index <> 58) Then 'index 56 & 58 fault in
sequence 2
Color = .EffectParameters.Color2.RGB
' Else
' Color = 0
' End If
Case msoAnimEffectChangeFillColor
Color = .Shape.Fill.BackColor.RGB
Case Else
Color = 0
End Select
Write #1, .Shape.Name; .Index; .EffectType; .Timing.Duration; Direction; _
.Timing.TriggerType; .Exit; Color; .DisplayName
End With
Next C
End With
Close #1
lngReturn = Shell("NOTEPAD.EXE " & FileName, vbNormalFocus)
End Sub

'I take the output file from above, rename, edit and read it back in to
modify my sequences
' do to the large number of animations on some pages. The presentation is
270+ slides.
' The system supplies makeup water to the reactor and is used in training
new operators.
' may need to change file paths.

Sub ReadSequences()
Dim objSequence As Sequence
Dim objShape1 As Shape
Dim objShape2 As Shape
Dim objEffect1 As Effect
Dim ShapeName As String
Dim Index, EffectType, Speed, Direction, Start, ExitEffect As Integer
Dim Color As Long
With ActivePresentation.Slides(233)
Set objSequence = .TimeLine.InteractiveSequences.Add(1)
Set objShape1 = .Shapes("Normal")
Open "C:\temp1\inputfile.txt" For Input As #1
Do While Not EOF(1)
Input #1, ShapeName, Index, EffectType, Speed, Direction, Start,
ExitEffect, Color
Set objShape2 = .Shapes(ShapeName)
With objSequence
Set objEffect1 = .AddEffect(Shape:=objShape2, _
Effectid:=EffectType, _
Trigger:=Start)
With objEffect1
If EffectType = 22 Then
.EffectParameters.Direction = Direction
End If
If (EffectType <> 54) And (EffectType <> 60) Then
.Exit = ExitEffect
End If
.Timing.Duration = Speed
.Timing.TriggerShape = objShape1
Select Case EffectType
Case msoAnimEffectChangeLineColor
.EffectParameters.Color2 = Color
Case msoAnimEffectChangeFillColor
.Shape.Fill.BackColor.RGB = Color
Case Else
Color = 0
End Select
End With
End With
Loop
End With
Close #1
End Sub


-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
 
C

carbuthn

I narrowed the problem some, there is not one single way to determine the
color that the animation effect is applying. So finding the right property
is most of the problem. When you select the effects if the style is one
solid color (1st selection) you must use
Effect.Behaviors.Item(1).Seteffect.To (you don't need RGB), if you use the
(2nd Selection) you must use Effect.Behaviors.Item(1).ColorEffect.To.RGB.

I wrote a case statement that used Effect.Behaviors.Item(1).Type which
worked for most of the shapes but not all. The slide had msoAnimTypeSet for
the first & forth Selection and msoAnimTypeRGB for the second & third.

The effect option style has to be using a different constant to determine
which property to set. But I have not been able to locate it.

Do you know a way to find out were the value is stored that determines which
location the end color is stored in?

Thanks,
Chuck
 
C

carbuthn

Thanks anyway for the effort, I am most likely to far back to pick up any new
responses, I am still playing with the issue. If I could just find where the
color style on the effects page is stored. Of course if I had been born rich
I wouldn't have to worry about it.

Thanks again for your help.
Chuck
 

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