PP in Background for Macros

W

Wi11y13

I am finding I must have the Powerpoint application running in order to have
my macros (from a saved slide presentation) work properly. Does anyone know
how at the beginning of my macro I can invoke PP and make it invisible in the
background so the user does not see it.

Here is the scenario - If I edit my PP document, save it as PPTM and PPSM
(for the slide show) - do not close it - then invoke the PPSM file - all of
the macros run properly.

If I edit my PP document, save it as PPTM and PPSM - Close the document -
then invoke the PPSM file the macros do not work - I believe the macros that
will not work have to do with deleting slides or saving to another file while
in the slideshow.

Thanks for the help and if you need other information please ask.
 
W

Wi11y13

In case it helps here is the code...

Dim x As Long
Dim currentSlide As Long
Dim oTempPres As Presentation
Dim pathName As String

x = 0
pathName = ActivePresentation.Path
currentSlide = ActivePresentation.Slides("CertificateSlide").SlideIndex

' Save a temporary COPY of your presentation
With ActivePresentation
.SaveCopyAs "c:\temp.pptx"
End With
MsgBox ("saved temp copy")

' Open the copy and delete slides from IT
Set oTempPres = Presentations.Open("c:\temp.pptx")
MsgBox ("opened temp file")


With oTempPres

For x = .Slides.Count To 1 Step -1
If .Slides(x).SlideIndex <> currentSlide Then
.Slides(x).Delete
End If

Next
MsgBox ("deleted slides")

.SaveAs FileName:="c:\" & userName & " Red Flag Certificate.PDF",
fileformat:=ppSaveAsPDF
MsgBox ("Saved Certificate")

.Close
MsgBox ("closed file")

End With

' Delete the copy presentation
Kill ("c:\temp.pptx")

MsgBox ("Saved Certificate as C:\" & (userName) & " Certificate.PDF")

End Sub

I know that it is failing (by the output messages I stuck in for debugging
purposes) during the statement to open the temp file.

Also I received this copy from Steve on this site last week and I wanted to
give him the credit for this. As I said if I already have PP opened when I
invoke the saved slide show - everything works like a champ. But I can not
guarantee that all of those taking the traiining will be in that state.

Thanks. Any help would be greatly appreciated.
 
C

Chirag

Change the line:

Set oTempPres = Presentations.Open("c:\temp.pptx")

to:

Set oTempPres = Presentations.Open("c:\temp.pptx", WithWindow:=False)

When you start PowerPoint, you do not need to make it visible for this code
to run.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
W

Wi11y13

Thank you so much. Initial testing shows this seems to work. I really
appreciate the help and the quick response.
 

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