SlideShow printing current slide

C

Chris

I've created the following VBA to print the current slide
during a slide show and attached it to a control button.

Dim CurrSlide as Long
CurrSlide=SlideShowWindows(1).View.Slide.SlideNumber
With ActivePresentation.PrintOptions
.RangeType=ppPrintSlideRange
With .Ranges
.ClearAll
.Add CurrSlide, CurrSlide
End With
.NumberOfCopies=1
.OutputType=ppPrintOutputSlides
End With
ActivePresentation.PrintOut

This works fine with one slide show active but I usually
have 4 to 5 open and when moving to a different slide view
via hyperlinks, the code prints the first slide of the new
show not the current viewed slide.

Thanks,
Chris
 
S

Steve Rindsberg

I've created the following VBA to print the current slide
during a slide show and attached it to a control button.

Dim CurrSlide as Long
CurrSlide=SlideShowWindows(1).View.Slide.SlideNumber
With ActivePresentation.PrintOptions
.RangeType=ppPrintSlideRange
With .Ranges
.ClearAll
.Add CurrSlide, CurrSlide
End With
.NumberOfCopies=1
.OutputType=ppPrintOutputSlides
End With
ActivePresentation.PrintOut

This works fine with one slide show active but I usually
have 4 to 5 open and when moving to a different slide view
via hyperlinks, the code prints the first slide of the new
show not the current viewed slide.


When you launch a new slide show, it becomes Slideshow.Windows(1) as near as I
can tell, so your code is in effect saying "Print the current slide of the most
recently launched show."

Try:

Dim CurrSlide As Long
Dim lWindow As Long
Dim sPresentationName as string
Dim x As Long

sPresentationName = "ThePresentationYouWantToPrintFrom.PPT"

' Find the number of the window that holds the presentation you're after:
For x = 1 To SlideShowWindows.Count
If SlideShowWindows(x).Presentation.Name = sPresentationName Then
lWindow = x
End If
Next x

' Now use that window number instead of 1
CurrSlide = SlideShowWindows(lWindow).View.Slide.SlideNumber
With ActivePresentation.PrintOptions
.RangeType = ppPrintSlideRange
With .Ranges
.ClearAll
.Add CurrSlide, CurrSlide
End With
.NumberOfCopies = 1
.OutputType = ppPrintOutputSlides
End With
ActivePresentation.PrintOut
End Sub



--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA www.PowerPointLive.com
================================================
 
S

Steve Rindsberg

Thanks Steve.

That will work if I know the current presentation that the slideshow is in.
I figured this out and currently hardcode the slide show window by opening
all the slide shows in a certain order. Is there a way to get the
SlideShowWindow that the current slide show is in and pass that as a variable
to the print routine?

Something like the code here might be even simpler:

Determine which shape was clicked
http://www.rdpslides.com/pptfaq/FAQ00141.htm

That explains how to get the shape the user just clicked (ie, your "Print me"
button).

Shape.Parent will give you the slide the shape's on
The slide's .Parent gives you the name of the presentation

So Shape.Parent.Parent gives you the presentation's name.

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA www.PowerPointLive.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