PDA

View Full Version : vba ppt 2007/2010 compatibility issue



pptSam
01-20-2011, 04:53 AM
Hello Everybody

I have a problem running a ppt-application, programmed in ppt 2010 on a pc with office 2007 (including ppt) installed. Both Systems run on Vista.

The application runs fine on the 2010 version but has very confusing errors, when running it on the 2007 version.

That's what I wanted the vba-code to do:
When I click on a shape, the shape should change the border weight and color to appear "activated". All this, while running ppt in presentation-mode.

That's what happens:
When I click the shape, nothing happens on the screen. When I quit the presentation-mode by esc, I find, that the border has changed. When I start the presentation-mode again, the changes are displayed. But the changes are not as intended: while the border weight is correct, the colour is not (it appears black instead of red).

So, this are the problems I am facing:
1. The changes to a shape are not displayed (slide not "refreshed")
2. The change of the colour is wrong (black not red as programmed)

Here is the code I am using to mark the shape:
Remark: The original code is more complex, but my testing showed, that the other parts are running without problems. The variables PsglKlickVar and PsglPerf are public variables that originate from other modules.


Public Sub SetBorder(oshp As Shape)
Set Pshp = oshp

If PsglKlickVar = 1 Then
If PsglPerf = 1 Then
With Pshp.Line
.ForeColor.RGB = RGB(255, 0, 0) 'colour red
.Visible = msoTrue
.Weight = 4.5
End With
Else
With Pshp.Line
.ForeColor.RGB = RGB(0, 255, 0) 'colour green
.Visible = msoTrue
.Weight = 4.5
End With
End If
End If

End Sub

:think: I already wondered if all this has anything to do with the vba references but didn't get the answer...

pptSam
01-20-2011, 08:12 AM
Hello, it's me again. I found some information that may be useful to help to find a solution:

1. For one of the problems I had (not the one I described here) I found, that on the 2010 ppt a shape name I used in vba-code was in English (Freeform 9") and on the 2007 ppt it automatically changed to German -> The same shape now is called "Freihandform 9". When I changed the name in the vba code, the problem was solved. Strange enough, both ppt-versions I use are German versions.
2. I realized, that in ppt 2010 there is vba 7.0 installed. On the machine with ppt 2007, there is vba 6.5 installed. But I don't know yet, if this is of any relevance.:dunno

John Wilson
01-20-2011, 12:35 PM
First the line
Set Pshp = oshp
is redundant the way you have set it up oshp is always set to the clicked shape

In 2007 a recent update introduced a bug which stops the screen refreshing. There's a hotfix available
http://support.microsoft.com/kb/2412275
or delete the security update KB 982158

pptSam
01-21-2011, 08:12 AM
Hello John

Thank's a lot for your hint: it's good for me to know, that there is a bug involved in the slide-refresh-issue. Unfortunately I have no administrator rights, so I can't delete the security update.
So I kept on trying and found a way to work around the problem. I'm afraid, it's not very elegant, but at least it worked in my setting. I made VBA move the shape around a little bit (in fact not even a bit: Pshp.Top = Pshp.Top + 0) with the RefreshMe sub (I got it from the net and modified it a bit). So here is what I did:


Public Sub SetBorder(oshp As Shape)
Set Pshp = oshp

If PsglKlickVar = 1 Then
If PsglPerf = 1 Then
With Pshp.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0) 'colour red
.Weight = 4.5
End With
Call RefreshMe(Pshp)
Else
With Pshp.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 255, 0) 'colour green
.Weight = 4.5
End With
Call RefreshMe(Pshp)

End If
End If

End Sub


Public Sub RefreshMe(Pshp As Shape)
Dim Offset As Single
Pshp.Top = Pshp.Top + 0
DoEvents
End Sub



I don't know if there was a more elegant solution, but at least it works.

For the second problem (black border-colour instead of red), I changed in the "with"-code part, so that ".Visible = msoTrue" comes first. That solved the problem.

So far, I'm quite happy :thumb - but I still have more problems to solve. For these I think it's better to open up a new topic.

So thank's agian for your help, John...