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