Event Handler Problem

G

Gil_H

Hi Ev1,
Iv'e Created an addin that uses a commandbar to open macros.
It works great on my computer and on another.
But in third computer it fails. It Loads the addin, presents the
toolbar with an error message:
"compile error in a hidden class"
What is hidden?
The class is attached? what error may be in my event handler class?
Here is the code:

Public WithEvents PPTEvent As Application
Dim Tmp As String
Dim MyShapes As Shapes
Dim CurrentSlide As Long
Dim EffectTypeStr As String
Dim i As Integer
Dim CopyAnimationSource As Shape
Dim CopyAnimationDest As Shape
Dim JoinMotionSource As Shape
Dim JoinMotionDest As Shape
Dim ShapeArray As Shapes
Dim MoveToSource As Shape
Dim MoveToDest As Shape
Dim PictureSource As Shape
Dim PictureDest As Shape
Dim ShapeToPolygon As Shape
Dim oShape As Shape
Dim Pos As Integer
Dim Res As Integer
Dim ToolbarIndex As Integer
'The Numbers that the command bar buttons got when toolbar initialized:
'ButtonShapeList = 1
'ButtonAnimationList = 2
'ButtonCopyAnimation = 3
'ButtonMotionPath = 4
'ButtonJoinMotionPaths = 5
'ButtonJoinMotionPathsFromCurrentPos = 6
'ButtonMoveTo = 7
'ButtonPictureCopy = 8
'ButtonPictureFromFile = 9
'ButtonShapeToPolygon = 10
Dim ButtonShapeList As CommandBarButton
Dim ButtonAnimationList As CommandBarButton
Dim ButtonCopyAnimation As CommandBarButton
Dim ButtonMotionPath As CommandBarButton
Dim ButtonJoinMotionPaths As CommandBarButton
Dim ButtonJoinMotionPathsFromCurrentPos As CommandBarButton
Dim ButtonMoveTo As CommandBarButton
Dim ButtonPictureCopy As CommandBarButton
Dim ButtonPictureFromFile As CommandBarButton
Dim ButtonShapeToPolygon As CommandBarButton

Private Sub PPTEvent_WindowSelectionChange(ByVal Sel As Selection)
'Setting The index Toolbar
ToolbarIndex = Module8.GetToolbarIndex

Start:
'Setting CommandBar Buttons
Set ButtonShapeList = Application.CommandBars(ToolbarIndex).Controls(1)
Set ButtonAnimationList =
Application.CommandBars(ToolbarIndex).Controls(2)
Set ButtonCopyAnimation =
Application.CommandBars(ToolbarIndex).Controls(3)
Set ButtonMotionPath =
Application.CommandBars(ToolbarIndex).Controls(4)
Set ButtonJoinMotionPaths =
Application.CommandBars(ToolbarIndex).Controls(5)
Set ButtonJoinMotionPathsFromCurrentPos =
Application.CommandBars(ToolbarIndex).Controls(6)
Set ButtonMoveTo = Application.CommandBars(ToolbarIndex).Controls(7)
Set ButtonPictureCopy =
Application.CommandBars(ToolbarIndex).Controls(8)
Set ButtonPictureFromFile =
Application.CommandBars(ToolbarIndex).Controls(9)
Set ButtonShapeToPolygon =
Application.CommandBars(ToolbarIndex).Controls(10)


If Not Sel.Type = ppSelectionNone Then
If Not Sel.ShapeRange.Count > 1 Then
Res = vbFalse

ButtonMoveTo.Enabled = True
Tmp = Sel.ShapeRange.Type
Tmp = Left(Tmp, 7)

'************************** Pictures
Setup*****************************
If Sel.Type = ppSelectionShapes And (Sel.ShapeRange.Type =
msoPicture _
Or Tmp = "Picture") Then
ButtonPictureCopy.Enabled = True
ButtonPictureFromFile.Enabled = True
Else
ButtonPictureCopy.Enabled = False
ButtonPictureFromFile.Enabled = False
End If

If ButtonPictureCopy.State = msoButtonUp Then
Tmp = Sel.ShapeRange.Name
ButtonPictureCopy.Enabled = True
Set PictureSource = SetCopyAnimationSource(Tmp)
Else
ButtonPictureCopy.Enabled = False
End If
If ButtonPictureCopy.State = msoButtonDown Then
Tmp = Sel.ShapeRange.Type
Tmp = Left(Tmp, 7)
If Sel.Type = ppSelectionShapes And (Sel.ShapeRange.Type =
msoPicture _
Or Tmp = "Picture") Then
Tmp = Sel.ShapeRange.Name
Set PictureDest = SetCopyAnimationSource(Tmp)
If Not PictureSource.Name = PictureDest.Name Then

ButtonPictureCopy.State = msoButtonUp
'Calling function to make the change
Res = Module6.PictureCopyProperties(PictureSource,
PictureDest)

Res = MsgBox("Make The Change?", vbOKCancel,
"Picture Copier")
If Res = vbOK Then

Set PictureSource = Nothing
Set PictureDest = Nothing
ButtonPictureCopy.State = msoButtonUp

ActivePresentation.Slides(CurrentSlide).Shapes(1).Select
GoTo Start
End If

End If
End If

Set PictureSource = Nothing
Set PictureDest = Nothing
ButtonPictureCopy.State = msoButtonUp
Else
ButtonPictureCopy.State = msoButtonUp
End If

If Not Res = vbOK Then

Tmp = Sel.ShapeRange.Name
If Sel.ShapeRange.AutoShapeType = msoShapeRightTriangle Or
msoShapeDiamond _
Or msoShapeRectangle Or msoShapeIsoscelesTriangle Then
ButtonShapeToPolygon.Enabled = True
Else
ButtonShapeToPolygon.Enabled = False
End If
Tmp = Sel.ShapeRange.Name
If IsShapeMotioned(Tmp) = 1 Then
ButtonMotionPath.Enabled = True
ButtonJoinMotionPaths.Enabled = True
ButtonJoinMotionPathsFromCurrentPos.Enabled = True
Else
ButtonMotionPath.Enabled = False
ButtonJoinMotionPaths.Enabled = False
ButtonJoinMotionPathsFromCurrentPos.Enabled = False
End If
If ButtonJoinMotionPaths.State = msoButtonUp Then
Tmp = Sel.ShapeRange.Name
If IsShapeMotioned(Tmp) = 1 Then
ButtonJoinMotionPaths.Enabled = True
Set JoinMotionSource = SetCopyAnimationSource(Tmp)
Else
ButtonJoinMotionPaths.Enabled = False
End If
End If
If ButtonJoinMotionPaths.State = msoButtonDown Then
Tmp = Sel.ShapeRange.Name
Set JoinMotionDest = SetCopyAnimationSource(Tmp)
Pos = 1
'Just to check if we succeded
Res = Module5.InitializeMotion(JoinMotionSource,
JoinMotionDest, Pos)
ButtonJoinMotionPaths.State = msoButtonUp
Set JoinMotionSource = Nothing
Set JoinMotionDest = Nothing
Else
ButtonJoinMotionPaths.State = msoButtonUp
End If
Tmp = Sel.ShapeRange.Name
If ButtonMoveTo.State = msoButtonUp Then
Set MoveToSource = SetCopyAnimationSource(Tmp)
End If
If ButtonMoveTo.State = msoButtonDown Then
Tmp = Sel.ShapeRange.Name
Set MoveToDest = SetCopyAnimationSource(Tmp)
Res = MoveTo(MoveToSource, MoveToDest)
ButtonMoveTo.State = msoButtonUp
ButtonMoveTo.Enabled = False
Set MoveToSource = Nothing
Set MoveToDest = Nothing

Else
ButtonMoveTo.State = msoButtonUp
End If
If ButtonJoinMotionPathsFromCurrentPos.State = msoButtonUp Then
Tmp = Sel.ShapeRange.Name
If IsShapeMotioned(Tmp) = 1 Then
ButtonJoinMotionPathsFromCurrentPos.Enabled = True
Set JoinMotionSource = SetCopyAnimationSource(Tmp)
Else
ButtonJoinMotionPathsFromCurrentPos.Enabled = False
End If
End If
If ButtonJoinMotionPathsFromCurrentPos.State = msoButtonDown
Then
Tmp = Sel.ShapeRange.Name
Set JoinMotionDest = SetCopyAnimationSource(Tmp)
Pos = 0
'Just to check if we succeded
Res = Module5.InitializeMotion(JoinMotionSource,
JoinMotionDest, Pos)
ButtonJoinMotionPathsFromCurrentPos.State = msoButtonUp
Set JoinMotionSource = Nothing
Set JoinMotionDest = Nothing
Else
ButtonJoinMotionPathsFromCurrentPos.State = msoButtonUp
End If
If ButtonCopyAnimation.State = msoButtonUp Then
Tmp = Sel.ShapeRange.Name
If IsShapeAnimated(Tmp) = 1 Then
ButtonCopyAnimation.Enabled = True
Set CopyAnimationSource = SetCopyAnimationSource(Tmp)
Else
ButtonCopyAnimation.Enabled = False
End If
End If
If ButtonCopyAnimation.State = msoButtonDown Then
Tmp = Sel.ShapeRange.Name
Set CopyAnimationDest = SetCopyAnimationSource(Tmp)
'Just to check if we succeded
Res = Module2.Initialize(CopyAnimationSource,
CopyAnimationDest)
ButtonCopyAnimation.State = msoButtonUp
Set CopyAnimationSource = Nothing
Set CopyAnimationDest = Nothing
Else
ButtonCopyAnimation.State = msoButtonUp
End If

End If 'Picture Selected Bug

Else 'There are more than 1 Shapes selected
ButtonPictureFromFile.Enabled = False
ButtonMotionPath.Enabled = False
ButtonShapeToPolygon.Enabled = False
ButtonCopyAnimation.State = msoButtonUp
ButtonCopyAnimation.Enabled = False
ButtonJoinMotionPaths.State = msoButtonUp
ButtonJoinMotionPaths.Enabled = False
ButtonJoinMotionPathsFromCurrentPos.State = msoButtonUp
ButtonJoinMotionPathsFromCurrentPos.Enabled = False
ButtonMoveTo.State = msoButtonUp
ButtonMoveTo.Enabled = False
ButtonPictureCopy.State = msoButtonUp
ButtonPictureCopy.Enabled = False

End If
Else 'There are No Shapes selected
ButtonPictureFromFile.Enabled = False
ButtonMotionPath.Enabled = False
ButtonShapeToPolygon.Enabled = False
ButtonCopyAnimation.State = msoButtonUp
ButtonCopyAnimation.Enabled = False
ButtonJoinMotionPaths.State = msoButtonUp
ButtonJoinMotionPaths.Enabled = False
ButtonJoinMotionPathsFromCurrentPos.State = msoButtonUp
ButtonJoinMotionPathsFromCurrentPos.Enabled = False
ButtonMoveTo.State = msoButtonUp
ButtonMoveTo.Enabled = False
ButtonPictureCopy.State = msoButtonUp
ButtonPictureCopy.Enabled = False
End If
End Sub

Function IsShapeMotioned(Tmp)
IsShapeMotioned = 0
If ActivePresentation.Windows(1).View.Type = ppViewNormal Then
CurrentSlide = ActivePresentation.Windows(1).View.Slide.SlideIndex
With ActivePresentation.Slides(CurrentSlide).TimeLine
For i = 1 To .MainSequence.Count
If .MainSequence(i).Shape.Name = Tmp Then
EffectTypeStr =
Module3.GetMSOAnimEffect(.MainSequence(i).EffectType)
EffectTypeStr = Replace(EffectTypeStr,
"msoAnimEffect", "")
EffectTypeStr = Left(EffectTypeStr, 4)
If (EffectTypeStr = "Path") Then
IsShapeMotioned = 1
End If
End If
Next
End With
End If
End Function


I really need your help!

Regards,
Gil H
 
S

Steve Rindsberg

Gil_H said:
Hi Ev1,
Iv'e Created an addin that uses a commandbar to open macros.
It works great on my computer and on another.
But in third computer it fails. It Loads the addin, presents the
toolbar with an error message:
"compile error in a hidden class"
What is hidden?

What version of PPT is in use on the computer?
If it's PPT97, events aren't supported, so your code wouldn't work.

You're also working with animation properties that don't exist in versions
prior to 2002, so you'd get compile errors in 2000 as well.
 
G

Gil_H

Hi,
On all computers PPT 2003 was installed, so there is no problem with
animation and events object.
I've read about a Microsoft bug "CommandBar Control Reference Becomes
Invalid Before COM Add-In's OnDisconnection Event Fires" Article found
at http://support.microsoft.com/kb/230876/ , does it have any
connection with my problem?

I've checked the Class code for errors, and it compiled well. I'm lost.

Gil H.

Steve Rindsberg כתב:
 
S

Shyam Pillai

The article is only valid if you have a COM add-in. I don't think that's the
case with your add-in.

Create your add-in without password protection and then load it on the
computer where it fails and it will highlight the errant line.

--
Regards,
Shyam Pillai

Animation Carbon
http://www.animationcarbon.com



Hi,
On all computers PPT 2003 was installed, so there is no problem with
animation and events object.
I've read about a Microsoft bug "CommandBar Control Reference Becomes
Invalid Before COM Add-In's OnDisconnection Event Fires" Article found
at http://support.microsoft.com/kb/230876/ , does it have any
connection with my problem?

I've checked the Class code for errors, and it compiled well. I'm lost.

Gil H.

Steve Rindsberg ???:
 
G

Gil_H

Hi,

I tried to add the addin to the non-friendly computer (PPT 2003
installed), and there is no option that the errant line will be marked,
because there is no code in the addin, and there is no option to debug
it.
I get Errors of Compile Error in Hidden Class and Compile Error in
Module, and i can't understand where is the bug.

Any Other Suggetstions?

Gil H.
 
G

Gil_H

Hi,

Could it be that the reason for my Errors is Trying the addin on
different OS, PPT Ver, and SP?

Gil H.
 
S

Steve Rindsberg

Gil_H said:
Hi,

Could it be that the reason for my Errors is Trying the addin on
different OS, PPT Ver, and SP?

Yes. That's why I asked several messages ago about this and you replied: "On
all computers PPT 2003 was installed, ..."

Let's start over. Please tell us:

- What versions of PowerPoint you're getting errors with
- The *exact* wording of any and all error messages
- What line the code breaks on

Without that, we're just guessing. That wastes your time and ours.
 
G

Gil_H

- What versions of PowerPoint you're getting errors with
- The *exact* wording of any and all error messages
- What line the code breaks on


Hi, I tried to install the Addin again, this time on XP Pro SP2, PPT
2003 - similar to my OS and Version.
As i load the addin i get "Compile Error: Can't find project or
library" - i got to VBE Debugger and it lights the Left Function (That
belongs to String Manipulation) in some class.
And exact message i got from another module - this time on LoadPicture
Method.
I looked at the VBE References and one of the Ref is: "Missing:
Microsoft Common Dialog Control 6.0 (SP 3)".
What can solve this Reference lack?
What do you suggest?

Gil H.
 
S

Steve Rindsberg

Hi, I tried to install the Addin again, this time on XP Pro SP2, PPT
2003 - similar to my OS and Version.
As i load the addin i get "Compile Error: Can't find project or
library" - i got to VBE Debugger and it lights the Left Function (That
belongs to String Manipulation) in some class.
And exact message i got from another module - this time on LoadPicture
Method.
I looked at the VBE References and one of the Ref is: "Missing:
Microsoft Common Dialog Control 6.0 (SP 3)".
What can solve this Reference lack?

Are you actually using the Common Dialog Control? From your code example, it
doesnt' seem so. On your own computer, try using Tools, References and remove
the check next to the common dialog control reference.

Will it still compile after you do that? If so, leave the project that way.
 
G

Gil_H

Are you actually using the Common Dialog Control? From your code example, it
doesnt' seem so. On your own computer, try using Tools, References and remove
the check next to the common dialog control reference.

Yes, I do. This common dialog control is used to open the common dialog
in one of my macros (modules). I tried to remove it and the macro
didn't open the common dialog.

I tested the addin on another computer (XP Pro Version 2002 SP 2, PPT
2003 - same as mine) and the addin worked great. Is there a way to make
it compatible with other computers?
Except that reference there is that Left function error. Which
reference is responsible for that function?

Gil H.
 
A

Austin Myers

Gil,

The common dialog control is installed with Visual Basic. To use it on
other machines you will have to install it and register it.

Austin Myers
MS PowerPoint MVP Team

Provider of PFCMedia, PFCPro, PFCExpress
http://www.pfcmedia.com
 
S

Steve Rindsberg

Yes, I do. This common dialog control is used to open the common dialog
in one of my macros (modules). I tried to remove it and the macro
didn't open the common dialog.

The common dialog control isn't part of Office, so may not be present on the other
computer where this isn't working. If you really need to use it, you'll have to
build an installer that installs and registers it on target machines.

For more about that, I'd ask on the newsgroup that supports whatever other
programming tool you have that includes the common dialog control (VB, etc).

Or visit sites like Randy Birch's
http://vbnet.mvps.org/

where you can get some first-rate examples of how to use the common dialog via win
api calls and avoid having to ship any controls.
I tested the addin on another computer (XP Pro Version 2002 SP 2, PPT
2003 - same as mine) and the addin worked great. Is there a way to make
it compatible with other computers?
Except that reference there is that Left function error. Which
reference is responsible for that function?

This?

Tmp = Sel.ShapeRange.Type
Tmp = Left(Tmp, 7)

Left (or Left$) return the leftmost n characters as a string.
You've set Tmp = a Long
 

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