We are building a kiosk. Each slide has a video. Whenever the user navigates or returns to a slide, the video should restart. I have vba code that does this but on 1st run, powerpoint doesn't appear to run the vba. Is there some sort of intialize module I need to add?
Only code:
Public Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
ActivePresentation.SlideShowWindow.View.ResetSlideTime
End Sub
Related
I have an Excel Add-In that I have created ( .xlam file ) I am trying to have this add-in create buttons on the right click menu so that I can quickly run a macro based on the selected cell. I added code to ThisWorkbook, and it works in the xlsm file. (I copied the code from HERE.) I SaveAs to an xlam, load the add-in, and I get nothing on the context menu. I have a feeling these subs do not load through the add-in. However, I can get code in Workbook_Open to function. Can someone point me in the right direction?
Private Sub Workbook_Deactivate()
On Error Resume Next
With Application
.CommandBars("Cell").Controls("Open Drawing").Delete
End With
On Error GoTo 0
End Sub
Private Sub Workbook_SheetBeforeRightClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Dim cmdBtn As CommandBarButton
On Error Resume Next
With Application
.CommandBars("Cell").Controls("Open Drawing").Delete
Set cmdBtn = .CommandBars("Cell").Controls.Add(Temporary:=True)
End With
With cmdBtn
.Caption = "Open Drawing"
.Style = msoButtonCaption
.OnAction = "Open_Drawing_Main"
End With
On Error GoTo 0
End Sub
You have to use AddinInstall event. I assume that your context menu procedure works fine. So double click on ThisWorkbook in the add-in file (before you install it and save it as xlam), select AddinInstall event from the upper write dropdown menu and place some code like this:
Private Sub Workbook_AddinInstall()
Call AddToRightClickMenuOptions_Main
End Sub
in this code AddToRightClickMenuOptions_Main is the sub that creates the context menu. Note that you may want to remove the context menu when you uninstall the add-in:
Private Sub Workbook_AddinUninstall()
Call DeleteFromRightClickMenuOptions_Main
End Sub
where DeleteFromRightClickMenuOptions_Main is the routine that removes the context menu (you can find the code easily on the internet)
An Excel Add-in (at least, the ones I have created) still have their own workbook. The Workbook_SheetBeforeRightClick and Workbook_Deactivate will run when the .xlam's workbook is either right-clicked or deactivated. If you want the code to run only for when the selected workbook is right-clicked or deactivated, you'll have to have the code in that specific workbook's code.
However
Since you are trying to get this to work with an add-in, I'm going to go through a few relevant points since once an Add-in is loaded, it (and it's features) are accessible from all other open workbooks.
If the option is added to the context menu whenever a page is right-clicked in any book (which it would (as coded, if it worked)), removing the context menu option when any workbook is deactivated won't have any visible effect, as the next time a right-click happens the option will once again be visible.
Is there a reason why the context menu can't just be added when the add-in is opened (add-in's Workbook_Open), and removed when it's closed(add-in's Workbook_BeforeClose)? (As this will visibly have the same effect as the above code.)
I have Microsoft Office PowerPoint 2007. I want to make it so that it will start a specific animation when I press the F4 key. I currently have the following:
Sub DoAnimation()
End Sub
Sub auto_open()
Application.OnKey "{F4}","DoAnimation"
End Sub
So how would I start the animation in the DoAnimation sub?
Powerpoint has an event SlideShowNextSlide which is triggered just before the slide show transitioned to the next slide.
What is the event that is triggered after the slide show has transitioned to the next slide?
You'll want to bookmark this page from Chirag Dalal:
http://www.officeoneonline.com/vba/events_version.html
I'm not sure that the specific event you're looking for exists.
But something like this might do the job:
Sub OnSlideShowPageChange(ByVal Wn As SlideShowWindow)
MsgBox Wn.View.Slide.SlideIndex
End Sub
This event fires during a slide show when the slide changes to either next slide or previous slide.
I kept a userform control button in my worksheet to fire up a macro, which in turn shows a user form, In the form I wish to display the opened files in checkboxes(using the Workbooks collection).I wish to run a macro that performs action for the user selected files only.
So for the button in my worksheet, I have assigned the following macro
Private Sub Button2_Click()
Load MyForm
MyForm.Show
End Sub
At first I kept the below code in the module where my macro sub is there.Since it's not working, I right clicked on user form and selected view code and kept the below code there.But still it's showing the same static designed user form, not the dynamic.I kept breakpoint at both load Myform and MYform.Show() and I stepped through code.It never went into intialize or activate method at all.
Private Sub MyForm_Activate()
'for checking the whether this method is called or not I am trying to change caption
MyForm.LabelSelectFile.Caption = "dhfdfldkfldzjf;zdfkz;d"
Dim mymyWorkBook As Workbook
For Each mymyWorkBook In Workbooks
'code for creating checkbox based on the file name displayed by the workbook collection
Next mymyWorkBook
End Sub
I can't understand why that event is not getting triggered.Please help me to overcome this.Thanks in advance
Even though the name of the form is MyForm, you still need to use userform.
'~~> in your worksheet
Private Sub Button2_Click()
MyForm.Show
End Sub
'~~> In the userform code area
Private Sub UserForm_Initialize()
'~~> Your code here
End Sub
or
Private Sub UserForm_Activate()
End Sub
The best is to always select the event from the drop down, rather than typing it
I'm trying to write a vba macro that can be called in edit-mode in PowerPoint 2007-2010.
I can easily add a Command Button to a presentation. However, this button can only be clicked to trigger the vba macro while in slideshow mode.
However, what I would like to do is have this button trigger the associated vba macro while in edit mode. Clicking on it in edit mode allows me to change its size etc, but it doesn't call the macro.
In Excel on the other hand, I get exactly the expected behaviour when I insert a button -> clicking on it calls the vba action.
So how can I create a button (or other element that acts the same way) that calls a vba macro during edit view in PowerPoint. The only way I can think of is using a ribbon action, however this is unpractical in this case, because the macro will modify a shape that is associated with the button and there might be several of these shapes per slide that should each have their own button.
The only way I can think of is using a ribbon action, however this is unpractical in this case, because the macro will modify a shape that is associated with the button and there might be several of these shapes per slide that should each have their own button.
Depending on what you're trying to do, a ribbon button that launches a macro might be quite practical. The macro could operate on the current selection (and test the current selection to ensure that it's something appropriate).
With ActiveWindow.Selection.ShapeRange
' operate on the currently selected shapes
End with
just answer it a some where else also
it is possible to do so all you need is download this file
http://www.officeoneonline.com/eventgen/EventGen20.zip
install it
create a class module
paste this code
Option Explicit
Public WithEvents PPTEvent As Application
Private Sub Class_Initialize()
End Sub
Private Sub PPTEvent_WindowSelectionChange(ByVal Sel As Selection)
If Sel.Type = ppSelectionShapes Then
If Sel.ShapeRange.HasTextFrame Then
If Sel.ShapeRange.TextFrame.HasText Then
If Trim(Sel.ShapeRange.TextFrame.TextRange.Text) = "Text inside your shape" Then
Sel.Unselect
yoursub
End If
End If
End If
End If
End Sub
insert a new module
paste this code
Dim cPPTObject As New Class1
Dim TrapFlag As Boolean
Sub TrapEvents()
If TrapFlag = True Then
MsgBox "Already Working"
Exit Sub
End If
Set cPPTObject.PPTEvent = Application
TrapFlag = True
End Sub
Sub ReleaseTrap()
If TrapFlag = True Then
Set cPPTObject.PPTEvent = Nothing
Set cPPTObject = Nothing
TrapFlag = False
End If
End Sub
Sub yoursub()
MsgBox "Your Sub is working"
End Sub
Now run TrapEvents and whenver you will click shape with that text in it your sub will run
Credits to the person who wrote this http://www.officeoneonline.com/eventgen/eventgen.html