Help! Macro suddenly not working?!

G

Geoff Cox

Hello,

The macro below has been working but suddenly nothing happens when I
run it!? It has been inserting an action button in the last slide of a
series of ppt files.

Any ideas please? Any obvious syntax error? Oddly the VBA editor debug
comes up with no errors.

Geoff

Sub ForEachPresentation()
' Run a macro of your choosing on each presentation in a folder

Dim rayFileList() As String
Dim FolderPath As String
Dim FileSpec
Dim strTemp As String
Dim x As Long

' EDIT THESE to suit your situation
FolderPath = "c:\fred\activities\" ' Note: MUST end in \
FileSpec = "*.ppt"
' END OF EDITS

' Fill the array with files that meet the spec above
ReDim rayFileList(1 To 1) As String
strTemp = Dir$(FolderPath & FileSpec)
While strTemp <> ""
rayFileList(UBound(rayFileList)) = FolderPath & strTemp
ReDim Preserve rayFileList(1 To UBound(rayFileList) + 1) As
String
strTemp = Dir
Wend

' array has one blank element at end - don't process it
' don't do anything if there's less than one element
If UBound(rayFileList) > 1 Then
For x = 1 To UBound(rayFileList) - 1
Call MyMacro(rayFileList(x))
Next x
End If

End Sub

Sub MyMacro(strMyFile As String)
' this gets called once for each file that meets the spec you enter in
ForEachPresentation
' strMyFile is set to the file name each time

' Probably at a minimum, you'd want to:
Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)

With oPresentation

With ActivePresentation.Slides(ActivePresentation.Slides.Count)_
..Shapes.AddShape(msoShapeActionButtonForwardorNext, 189.88, _
389.12,153.12, 39.62)

With .ActionSettings(ppMouseClick)
.Hyperlink.Address = "C:\fred\menu.ppt"
.SoundEffect.Type = ppSoundNone
.AnimateAction = msoTrue
End With

' delete the next five lines if you don't need to add a mouseover
With .ActionSettings(ppMouseOver)
.Action = ppActionNone
.SoundEffect.Type = ppSoundNone
.AnimateAction = msoFalse
End With

End With

oPresentation.Save
oPresentation.Close


End With
End Sub
 
G

Geoff Cox

Hello,

The macro below has been working but suddenly nothing happens when I
run it!? It has been inserting an action button in the last slide of a
series of ppt files.

Any ideas please? Any obvious syntax error? Oddly the VBA editor debug
comes up with no errors.

'umble apologies - a typo ...

Geoff
 
S

Shyam Pillai

It works for. Please try restarting PowerPoint. Also confirm if the issue is
specific to a presentation.
 
G

Geoff Cox

It works for. Please try restarting PowerPoint. Also confirm if the issue is
specific to a presentation.

Shyam,

I guess you missed my posting saying it was a typo!

But can you help with this? By the way you say it worked but did the
buttons have the entrance/dissolve animation? My problem follows!

The code should put an action button on the last slide of each of a
series of presentations with custom animation entrance/dissolve. The
button is installed but the animation is not there!

I may have got the wrong approach. Not knowing much about VBA yet I
used some code of Steve Rinberg's code for putting the button in the
last slides and added the code for creating the button myself. I got
this code from using Record Macro.

The code produced follows. This code does work in the ppt file within
which it was created but as I say it does not give the animation when
used for the many slides.

Just a simple question! Does it in fact contain any code for the
custom animation entrance/dissolve?! I cannot see it. If not how come
it works in the original ppt file?!

There is another aspect which I may have got wrong. I want this button
to appear after all the other animations on each slide have taken
place. On the slide where I created it there was only 1 other
animation (some text appears) so the button will be the second and
last animation but of course on the other slides it might have to be
the 3rd, 4th, fifth or whatever....

Look forward to hearing from you!

Cheers

Geoff

______________________________________

Sub add()
'
' Macro recorded 13/04/2006 by Geoff Cox
'

ActiveWindow.Selection.SlideRange.Shapes.AddShape_
(msoShapeActionButtonForwardorNext, 263.62, 457.12, 181.38,_
39.62).Select

With ActiveWindow.Selection.ShapeRange.ActionSettings(ppMouseClick)
.Hyperlink.Address = "C:\fred\menu.ppt"
.SoundEffect.Type = ppSoundNone
.AnimateAction = msoTrue
End With

With ActiveWindow.Selection.ShapeRange.ActionSettings(ppMouseOver)
.Action = ppActionNone
.SoundEffect.Type = ppSoundNone
.AnimateAction = msoFalse
End With
End Sub

__________________________________
 
G

Geoff Cox

Just a simple question! Does it in fact contain any code for the
custom animation entrance/dissolve?! I cannot see it. If not how come
it works in the original ppt file?!

Shyam,

I have just realised that the code does NOT contain anything to do
with animation!

How do I get that into the code!?

Plus - I cannot seem to find any tutorial info on how to write
PowerPoint VBA on the Net - just sample code examples, which assume
too much knowledge - can you point to anything? Any books published?

Cheers

Geoff

Sub add()
'
' Macro recorded 13/04/2006 by Geoff Cox
'
ActiveWindow.Selection.SlideRange.Shapes.AddShape _
(msoShapeActionButtonForwardorNext, 269.25, 468.5, 192.75,
39.62).Select
With ActiveWindow.Selection.ShapeRange.ActionSettings(ppMouseClick)
.Hyperlink.Address = "C:\fred\menu.ppt"
.SoundEffect.Type = ppSoundNone
.AnimateAction = msoTrue
End With
With ActiveWindow.Selection.ShapeRange.ActionSettings(ppMouseOver)
.Action = ppActionNone
.SoundEffect.Type = ppSoundNone
.AnimateAction = msoFalse
End With
End Sub
 
G

Geoff Cox

On Thu, 13 Apr 2006 07:32:06 +0100, Geoff Cox

Shyam,

Further revelation! I now read that it is NOT possible to use Macro
Record for animations in PPT 2003!!

I have tried the suggestion of turning off the new animations in
options and now get following code for animation but when I try to add
this to my code for adding buttons to multiple ppt files I keep
getting errors ... I know that I need ActivePresentation rather than
ActiveWindow but can you tell me how the code should be changed to
work in this macro?

Thanks

Geoff


Sub newadd()
'
' Macro recorded 13/04/2006 by Geoff Cox
'

With ActiveWindow.Selection.ShapeRange.AnimationSettings
.Animate = msoTrue
.EntryEffect = ppEffectDissolve
.TextLevelEffect = ppAnimateByAllLevels
.AnimateBackground = msoTrue
End With
End Sub
 
G

Geoff Cox

It works for. Please try restarting PowerPoint. Also confirm if the issue is
specific to a presentation.

Shyam,

The latest round in this saga!

I have just found out that the Record Macro in PowerPoint 2003 will
not work with the latest animations!! From a posting of yours I think.

I have wasted hours trying to do just that!

I also see that you can turn off the "new animations" in Options and
them the Record Macro does come up with the code. I have been able to
use that to add the dissolve animation code to my macro and that works
OK.

Would be nice if the MS Record Macro team could keep up with the other
programmers!!

Cheers

Geoff
 

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