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
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