Through VBA, how would I go about getting the count of slides for a
PPT file that isn't open?
Essentially this:
ActivePresentation.Slides.Count
but for a file instead of the currently running slideshow.
I just can't get the syntax correct, so if any one could stear me in
the right direction, that would be great.
Thanks!
John Wilson - 27 May 2008 20:35 GMT
AFAIK you would need to open the file, count the slides and close it again
set opres=Presentations.Open(filepath)
Islides=opres.Slides.Count
opres.Close

Signature
-------------------------------------------
Amazing PPT Hints, Tips and Tutorials
http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
> Through VBA, how would I go about getting the count of slides for a
> PPT file that isn't open?
[quoted text clipped - 9 lines]
>
> Thanks!
PHason - 28 May 2008 15:21 GMT
Thank you Austin.
And thanks, John for the sample code.
I'm almost getting it, but I get a "Runtime error '13' -- type
mismatch" when I run it. I'm guessing I need to use a different object
than Presentations, but I'm not sure what. It stops right on the "set
opres=Presentations.Open(filepath)" line, but when I End the code the
presentation being referenced is opened by the code, yet there is that
error.
I'm using PowerPoint 2003 if that makes a difference.
Any suggestions.
Thanks a bunch.
On May 27, 2:35 pm, John Wilson <john AT technologytrish.co DOT uk>
wrote:
> AFAIK you would need to open the file, count the slides and close it again
>
[quoted text clipped - 23 lines]
>
> - Show quoted text -
T Lavedas - 28 May 2008 15:41 GMT
> Thank you Austin.
>
[quoted text clipped - 43 lines]
>
> > - Show quoted text -
No, the Open method must take a Presentations object as its
expression. The problem lies somewhere else. I suppose it could be
in how you have dimensioned the opres variable, if you did dimension
it.
I think you need to post some actual code to get a correct diagnosis.
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
PHason - 28 May 2008 16:09 GMT
> No, the Open method must take a Presentations object as its
> expression. The problem lies somewhere else. I suppose it could be
[quoted text clipped - 7 lines]
>
> - Show quoted text -
That is a good idea. I had taken it down to the simplest form to try
to determine where the issue is, but I still run into the same
problem. I've tried both a UNC path and a local path to the file and I
get the same result.
Here is the code:
====================
Public Sub Test()
Dim opres As Presentations
Set opres = Presentations.Open("\\Ph-tv\PH-TV\Installs.ppt")
opres.Close
End Sub
====================
When I run it, I first get an error that states "Compile error: Method
or data member not found" for the "opres.Close" line.
If I remark out the "opres.Close" line, then I get the "Runtime error
'13': Type mismatch" error on the "Set opres = Presentations.Open("\
\Ph-tv\PH-TV\Installs.ppt")" line. Like I stated before, an additional
session of PowerPoint does start and the file is opened, but the code
stops running at that line.
Thanks.
T Lavedas - 28 May 2008 16:34 GMT
> > No, the Open method must take a Presentations object as its
> > expression. The problem lies somewhere else. I suppose it could be
[quoted text clipped - 35 lines]
>
> Thanks.
Take the 's' off the end of Presentations. The type that is returned
is a single Presentation, not the Presentations collection type.
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
PHason - 28 May 2008 16:45 GMT
> > > No, the Open method must take a Presentations object as its
> > > expression. The problem lies somewhere else. I suppose it could be
[quoted text clipped - 43 lines]
>
> - Show quoted text -
Tom, thanks a bunch, that did the trick! I was getting tripped up that
the type is "Presentation", but then the function is
"Presentations.Open". Again, thanks a ton.
Austin Myers - 27 May 2008 20:56 GMT
As far as I know there is no way to do so without open the file.
Austin Myers
Microsoft PowerPoint MVP Team
Creator of PFCPro, PFCMedia and PFCExpress
http://www.playsforcertain.com
> Through VBA, how would I go about getting the count of slides for a
> PPT file that isn't open?
[quoted text clipped - 9 lines]
>
> Thanks!
Shyam Pillai - 28 May 2008 21:41 GMT
You can get the slide count without using PowerPoint. Search for DSOFile. It
is a microsoft component which allows you to retrieve document properties.
Sample code is included in the download.
Regards,
Shyam Pillai
Image Importer Wizard
http://skp.mvps.org/iiw.htm
> Through VBA, how would I go about getting the count of slides for a
> PPT file that isn't open?
[quoted text clipped - 9 lines]
>
> Thanks!