pptSam
01-21-2011, 09:16 AM
Hello again
So, as announced, this is the second post about my ppt 2007/2010 compatibility problems.
What I wanted to achieve:
I wrote some code to change the colour and border-weight when the shape is clicked. Then I introduced a code to turn the shape back to the original state, when it is klicked again (=deaktivated). I did this by storing the information on the original shape-state in special five-dimensional datafield variables. When needed, this information could be retrieved from these variables and the values applied to the shape. This worked fine in ppt 2010 but not anymore with ppt 2007. Here is the code I am using:
Public Sub KlickStatus(oshp as shape)
set Pshp = oshp
Dim sld As Slide
Dim shp As Shape
Set PshpKlickedShp(a, b, c, d, e) = Pshp
'stores the color of the shape
PsglShpColor(a, b, c, d, e) = Pshp.Line.ForeColor.RGB
'stores the visibility-state of the shape
PbolVisState(a, b, c, d, e) = Pshp.Line.Visible
'call the sub to change the color to "activated"
SetBorderActivated
end sub
Public Sub SetBorderActivated(oshp As Shape)
Set Pshp = oshp
With Pshp.Line
.ForeColor.RGB = RGB(255, 0, 0) 'colour red
.Visible = msoTrue
.Weight = 4.5
End With
end sub
'Now, I want to "deactivate" (=reset to original) the shape with the following code
Public Sub ResetBorder()
'first the script sets the variables a,b,c,d,e to the appropriate values (code not given here)
Dim sld As Slide
Dim shp As Shape
Dim Index As Single
Dim ID As Single
Set shp = PshpKlickedShp(a, b, c, d, e)
ID = shp.ID
Set sld = PshpKlickedShp(a, b, c, d, e).Parent
Index = sld.SlideIndex
With Application.ActivePresentation.Slides(Index).Shapes(ID).Line
.Weight = PsglWeight(a, b, c, d, e)
.ForeColor.RGB = PsglShpColor(a, b, c, d, e)
.Visible = PbolVisState(a, b, c, d, e)
End With
end sub
As I said: it worked in ppt 2010 but not with ppt 2007. In debug mode I find an error massage saying: "Shapes (unkonwn member): Integer out of range. 19 is not in the valid range of 1 to 8."
The problem with this is, that the ShapeID 19 really is correct. So, I just don't understand the error.
Any help on this is highly appreciated...
So, as announced, this is the second post about my ppt 2007/2010 compatibility problems.
What I wanted to achieve:
I wrote some code to change the colour and border-weight when the shape is clicked. Then I introduced a code to turn the shape back to the original state, when it is klicked again (=deaktivated). I did this by storing the information on the original shape-state in special five-dimensional datafield variables. When needed, this information could be retrieved from these variables and the values applied to the shape. This worked fine in ppt 2010 but not anymore with ppt 2007. Here is the code I am using:
Public Sub KlickStatus(oshp as shape)
set Pshp = oshp
Dim sld As Slide
Dim shp As Shape
Set PshpKlickedShp(a, b, c, d, e) = Pshp
'stores the color of the shape
PsglShpColor(a, b, c, d, e) = Pshp.Line.ForeColor.RGB
'stores the visibility-state of the shape
PbolVisState(a, b, c, d, e) = Pshp.Line.Visible
'call the sub to change the color to "activated"
SetBorderActivated
end sub
Public Sub SetBorderActivated(oshp As Shape)
Set Pshp = oshp
With Pshp.Line
.ForeColor.RGB = RGB(255, 0, 0) 'colour red
.Visible = msoTrue
.Weight = 4.5
End With
end sub
'Now, I want to "deactivate" (=reset to original) the shape with the following code
Public Sub ResetBorder()
'first the script sets the variables a,b,c,d,e to the appropriate values (code not given here)
Dim sld As Slide
Dim shp As Shape
Dim Index As Single
Dim ID As Single
Set shp = PshpKlickedShp(a, b, c, d, e)
ID = shp.ID
Set sld = PshpKlickedShp(a, b, c, d, e).Parent
Index = sld.SlideIndex
With Application.ActivePresentation.Slides(Index).Shapes(ID).Line
.Weight = PsglWeight(a, b, c, d, e)
.ForeColor.RGB = PsglShpColor(a, b, c, d, e)
.Visible = PbolVisState(a, b, c, d, e)
End With
end sub
As I said: it worked in ppt 2010 but not with ppt 2007. In debug mode I find an error massage saying: "Shapes (unkonwn member): Integer out of range. 19 is not in the valid range of 1 to 8."
The problem with this is, that the ShapeID 19 really is correct. So, I just don't understand the error.
Any help on this is highly appreciated...