Printing Last Page Only Using VBA Code

G

Guest

I would like to print the last page of a power point document using OLE from
Access VBA Code.

I am able to print a complete document with:

Static oPPT As PowerPoint.Application
Static oPres As Presentation

Set oPres = GetObject(Filter_Filename & ".ppt")
oPres.PrintOut
oPres.Close
Set oPres = Nothing

How can I do that?


Thanks,

Gary
 
S

Shyam Pillai

Hi Gary,Dim SldNo As LongSldNo = ActivePresentation.Slides.CountWith
ActivePresentation.PrintOptions' Set the shaperange type to slides
..RangeType = ppPrintSlideRange .NumberOfCopies = 1 .Collate = msoTrue
..OutputType = ppPrintOutputSlides .PrintHiddenSlides = msoTrue
..PrintColorType = ppPrintBlackAndWhite .FitToPage = msoFalse
..FrameSlides = msoFalse' Clear existing ranges .Ranges.ClearAll' Set the
print range to last slide .Ranges.Add SldNo, SldNoEnd
WithActivePresentation.PrintOut-- Regards,Shyam PillaiToolbox:
http://skp.mvps.org/toolbox
 
G

Guest

I still need a little help here. I don't think I understood everything you
gave me here.

This is what I used:

Static SldNo As Long

SldNo = ActivePresentation.Slides.Count
With ActivePresentation.PrintOptions
.RangeType = ppPrintSlideRange
.NumberOfCopies = 1
.Collate = msoTrue
.OutputType = ppPrintOutputSlides
.PrintHiddenSlides = msoTrue
.PrintColorType = ppPrintBlackAndWhite
.FitToPage = msoFalse
.FrameSlides = msoFalse
.Ranges.ClearAll
.Ranges.Add SldNo, SldNoEnd
WithActivePresentation.PrintOut
End With


The variable SldNoEnd was not defined anywhere? I also tried giving it the
last slide number and it didn't work for me. I print all the slide out for
me.

Can you please tell me what I did wrong.

Thanks,

Gary
 
D

David M. Marcovitz

Just use SldNo instead of SldNoEnd. Alternatively, you could try the
following. It just doesn't set all the options that Shyam's code set, but
the defaults are likely to be OK. And if this simpler code mostly works,
you can try adding back in some of the options.

SldNo = ActivePresentation.Slides.Count
ActivePresentation.PrintOptions.OutputType = ppPrintOutputSlides
ActivePresentation.PrintOut From:=SldNo, To:=SldNo

--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 

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