Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / July 2008

Tip: Looking for answers? Try searching our database.

PowerPoint 2003 AddIns does not work in PowerPoint 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LostMyBrain - 24 Jul 2008 04:27 GMT
Hi,

I have a simple AddIns for PowerPoint that I wrote and it works fine on
version 2003. However, when trying to run it on 2007 it does not work as
expected.

In order to debug the problem, I removed all the non-relevant code and ended
up with a simple AddIns that open a form with two buttons "OK","Cancel". Once
the user press "OK" it creates a rectangular shape on the current slide and
close the form. As part of the code, this macro attaches a tag to the
rectangular so that when the user double-clicks on this shape it reopen the
form, but this time the buttons are "Work","Cancel".

In both 2003, 2007 the first part works fine and the new rectangular is
added to the slide. However, in 2007 the second part does not work.
Double-clicking the rectangular brings the picture toolbar and does not open
the form as expected. In 2003 it works find.

I can attach my .ppt file (and also the .ppa file) - but I don't see how to
attach files to this question.

Thank you.
Steve Rindsberg - 24 Jul 2008 15:45 GMT
> In order to debug the problem, I removed all the non-relevant code and ended
> up with a simple AddIns that open a form with two buttons "OK","Cancel". Once
[quoted text clipped - 10 lines]
> I can attach my .ppt file (and also the .ppa file) - but I don't see how to
> attach files to this question.

No need to attach the PPA, just copy and paste the relevant parts of the code
here in the message box.

Particularly, mention how you're trapping the doubleclick on the rectangle.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Live and in personable in the Help Center at PowerPoint Live
Sept 21-24, San Diego CA, USA
www.pptlive.com
LostMyBrain - 24 Jul 2008 17:01 GMT
Hi,

Here it is (using export option)
I attached 3 text files the Macros, MyForm and the section responsible for
trapping the double-click event.

Thanks.

---- Macros ----------------------
Attribute VB_Name = "Macros"
Sub NewTest()
Attribute NewTest.VB_Description = "Macro created 24.5.2007 by Zvika Ben-Haim"
   Load MyForm
   MyForm.ButtonRun.Caption = "Create"
   MyForm.Show
End Sub

Sub Auto_Open()
   ' Runs when the add-in is loaded
   MyForm.InitializeApp
End Sub

---- MyForm ----------------------
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} MyForm
  Caption         =   "Test"
  ClientHeight    =   1935
  ClientLeft      =   45
  ClientTop       =   330
  ClientWidth     =   5175
  OleObjectBlob   =   "MyForm.frx":0000
  StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "MyForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim theAppEventHandler As New appEventHandler

Sub InitializeApp()
   ' This enables us to capture application events, such as double-clicking
on
   ' an IguanaTex image
   Set theAppEventHandler.App = Application
   
   MenuItemCaption = "New Test..."
   
   ' Check if we have already added the menu item
   Dim initialized As Boolean
   Dim bef As Integer
   initialized = False
   bef = 1
   Dim Menu As CommandBars
   Set Menu = Application.CommandBars
   For i = 1 To Menu("Insert").Controls.Count
       With Menu("Insert").Controls(i)
           If .Caption = MenuItemCaption Then
               initialized = True
               Exit For
           ElseIf InStr(.Caption, "Dia&gram") Then
               bef = i
           End If
       End With
   Next
   
   ' Create the menu choice. The choice is created in the first
   ' position in the Insert menu.
   If Not initialized Then
       Dim NewControl As CommandBarControl
       Set NewControl = Menu("Insert").Controls.Add _
                             (Type:=msoControlButton, _
                              before:=bef)
       NewControl.Caption = MenuItemCaption
       NewControl.OnAction = "NewTest"
   End If
End Sub

Private Sub ButtonCancel_Click()
   MyForm.Hide
End Sub

Private Sub ButtonRun_Click()

If ButtonRun.Caption = "Create" Then
   Dim newShape As Shape
   Set newShape =
ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangle, 5, 25,
100, 50)
   newShape.Select
   newShape.Tags.Add "MYADDIN", "MyText"
End If
   
   MyForm.Hide
End Sub

---- Trapping the double-click event ----------------------
VERSION 1.0 CLASS
BEGIN
 MultiUse = -1  'True
END
Attribute VB_Name = "AppEventHandler"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Public WithEvents App As Application
Attribute App.VB_VarHelpID = -1

Private Sub App_WindowBeforeDoubleClick(ByVal Sel As Selection, ByRef Cancel
As Boolean)
   If Sel.Type = ppSelectionShapes Then
       If Sel.ShapeRange.Count = 1 Then
           With Sel.ShapeRange.Tags
               For i = 1 To .Count
                   If (.Name(i) = "MYADDIN") Then
                       Load MyForm
                       MyForm.ButtonRun.Caption = "Work !!"
                       MyForm.Show
                       Cancel = True
                       Exit Sub
                   End If
               Next
           End With
       End If
   End If
End Sub

> > In order to debug the problem, I removed all the non-relevant code and ended
> > up with a simple AddIns that open a form with two buttons "OK","Cancel". Once
[quoted text clipped - 24 lines]
> Sept 21-24, San Diego CA, USA
> www.pptlive.com
Shyam Pillai - 25 Jul 2008 16:19 GMT
WindowBeforeDoubleClick and WindowBeforeRightClick events don't work anymore
on the Slide itself. They work only in other views.

Regards,
Shyam Pillai

Image Importer Wizard
http://skp.mvps.org/iiw.htm

> Hi,
>
[quoted text clipped - 164 lines]
>> Sept 21-24, San Diego CA, USA
>> www.pptlive.com
LostMyBrain - 25 Jul 2008 16:32 GMT
Can you suggest me how to fix my code for 2007?
Is there any method that will work on both versions as is ?

> WindowBeforeDoubleClick and WindowBeforeRightClick events don't work anymore
> on the Slide itself. They work only in other views.
[quoted text clipped - 173 lines]
> >> Sept 21-24, San Diego CA, USA
> >> www.pptlive.com
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.