PowerPoint Show macro

U

UKNewbie

Hi all,

I'm having problems writing an open event macro with a powerpoint show (read
'show' as underlined) i.e. I can't figure it out at all.

Basically, I want the show to fire a background macro. As there is no open
event (like in excel), as far as I can tell, you have to build your own.

I've tried following the help file instructions for 'SlideShowBegin' and
'PresentationOpen' but without success.

Can any please explain how to go about this?

Many thanks as always...

Mike
 
U

UKNewbie

Thanks for the prompt reply Glen. Was useful when I got home - unfortunately,
our business network prohibits downloads such as zip files, so I had to wait
with baited breath.

Perhaps you would not mind helping with another query, for which I have
attached the code below. Don't laugh too hard at it - I'm still fairly new to
coding VBA (hence the moniker) and this is my first attempt with PoweePoint.

Basically, the PowerPoint slide keeps the work station unlocked and each
hour, switches to an Excel document which runs an automated report. Whilst
the Excel report is not running, the slide show runs with a shape that is
populated with the current time.

It waits for the clipboard to populate with a value (which Excel generates)
or until it times out, and then continues running the slide.

The problem - the show is not regaining focus once Excel has finished.

Would you, or someone, mind having a quick scan through the code and seeing
if there may be a solution. Oh, and the reason I AppActivate MS PowePoint and
then the slide is because it is the only was the workstation will not lock.

Thanks again,

____________________________________________________________________
Code
------
Public myDocument As Object
Dim RepVal As String
Dim RepTime
Dim Oldtime
Dim Response
Dim TextTime

Sub ASARunner()
counter = 1
Application.WindowState = ppWindowMinimized
ActivePresentation.SlideShowSettings.Run
On Error GoTo errorpoint
Set myDocument = ActivePresentation.Slides(1)
Dim myObj As New DataObject
Set myObj = New DataObject
Do
myObj.SetText ""
waiter (0.45)
RepTime = Format(Format(Right(Format(Now(), "hh:mm"), 2), "0") +
(Right(Format(Now(), "hh:mm:ss"), 2) / 60), "0.0")
TextTime = Format(Now(), "hh:mm:ss")
If RepTime > 1.1 And RepTime < 1.3 Then
AppActivate ("Global ASA Report v4.dev.xls"), False
SendKeys "^(+a)", True
Oldtime = Timer
Do
waiting = DoEvents
myObj.GetFromClipboard
On Error Resume Next
RepVal = myObj.GetText(1)
Loop Until RepVal = "Yes" Or Timer - Oldtime > 600
On Error GoTo errorpoint
If RepVal = "Yes" And TextTime > "09:00:00" And TextTime <
"17:00:00" Then
myObj.SetText ""
AppActivate ("Microsoft Excel - Global"), False
SendKeys "^(+b)", True
Oldtime = Timer
Do
waiting = DoEvents
myObj.GetFromClipboard
On Error Resume Next
RepVal = myObj.GetText(1)
Loop Until RepVal = "Done" Or Timer - Oldtime > 180
On Error GoTo errorpoint
If RepVal <> "Done" Then
AppActivate "PowerPoint Slide", False
MsgBox "There has been an error with Excel", vbOKOnly,
"Report..."
Exit Sub
End If
ElseIf RepVal = "Yes" And TextTime < "10:00:00" Or TextTime >
"17:00:00" Then
GoTo NextPoint
Else
AppActivate "PowerPoint Slide", False
MsgBox "There has been an error with Excel", vbOKOnly, "Report..."
Exit Sub
End If
End If

NextPoint:
myDocument.Shapes("Rectangle 9").TextFrame.TextRange.Text = TextTime
AppActivate "Microsoft PowerPoint", False
AppActivate "PowerPoint Slide", False
SlideShowWindows(Index:=1).View.First
waiter (0.45)
errorpoint:
If Err <> 0 Then
Response = MsgBox(Err.Description & vbNewLine & vbNewLine &
"Continue..?", vbYesNo + vbCritical)
If Response = 7 Then Exit Sub
End If
Loop Until TextTime > "16:12:00
-----------------------------------------------------------------------------------------------
End Sub
Sub waiter(wait)

Oldtime = Timer
Do
waiting = DoEvents
Loop Until Timer > Oldtime + wait

End Sub
____________________________________________________________________
 
B

Bill Dilworth

The line of code that will cause PowerPoint to re-seize focus (from within a
PowerPoint macro) is:

Application.Activate

Just plug it in before you need PowerPoint to have control again.


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
yahoo2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
U

UKNewbie

Bill,

Many thanks. Did not get chance to try this at work however, will do next
week. What you've said makes absolute sense though. Pretty stupid on my part
not to think of it.

Thanks again,

Mike
 

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