VBA in PPT - Options button & printing in slideshow

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to make a print macro that will print a given file depending on
the selection in the options buttons during a slideshow. The trouble right
now is that when I click the print button, the screenshow stops to open the
file that will be printed, prints the file and then I have to click "Resume
SlideShow" to continue my slideshow. How do I get a file to be printed out
in without interrupting my slideshow? I already turned on the "background
Printing" option but that didn't seem to do it.
Any help geatly appreciated.
 
Garbo,
Depends on the code you have used to send it to print. It you keep the
document window hidden for the document that is opened for printing you will
not experience this behavior. Alternately add SlideShowWindows(1).Activate
at the end of your code if that would suffice.
 
Thanks Shyam,

What code should I have used to send it to print? I don't know how to hide
the document window.

Private Sub CommandButton1_Click()
Presentations.Open FileName:="C:\filename.ppt", ReadOnly:=msoFalse
With ActivePresentation.PrintOptions
.RangeType = ppPrintAll
.NumberOfCopies = 1
.Collate = msoTrue
.OutputType = ppPrintOutputSlides
.PrintHiddenSlides = msoTrue
.PrintColorType = ppPrintBlackAndWhite
.FitToPage = msoFalse
.FrameSlides = msoFalse
.ActivePrinter = "hp LaserJet 1000"
End With
ActivePresentation.PrintOut
ActiveWindow.Close
End Sub

Do I need all of that? I just got it from recording a print macro but I'm
guessing there's an easier way?

Thanks again!
 
Garbo,
Use the following code:
' --------------------------------
Dim oPPT As Presentation
Set oPPT = Presentations.Open(FileName:="C:\filename.ppt",
ReadOnly:=msoFalse, _
WithWindow:=False)
With oPPT.PrintOptions
.RangeType = ppPrintAll
.NumberOfCopies = 1
.Collate = msoTrue
.OutputType = ppPrintOutputSlides
.PrintHiddenSlides = msoTrue
.PrintColorType = ppPrintBlackAndWhite
.FitToPage = msoFalse
.FrameSlides = msoFalse
.ActivePrinter = "hp LaserJet 1000"
' make this true if it fails to print accurately
.PrintInBackground = False
End With
oPPT.PrintOut
oPPT.Close
Set oPPT = Nothing
SlideShowWindows(1).Activate
'------------------------------------------

--
Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how
 
Hi Shyam,
I copied in the code as follows but it turned red on the line beginning with
"Set oPPT and ending with :=False). It highlighted the := after ReadOnly and
said Combile Error, expected - expression. What am I doing wrong? THANKS!

Private Sub CommandButton1_Click()
Dim oPPT As Presentation
Set oPPT = Presentations.Open(FileName:="C:\z_working\Trial_1.ppt",
ReadOnly:=msoFalse, _
WithWindow:=False)
With oPPT.PrintOptions
.RangeType = ppPrintAll
.NumberOfCopies = 1
.Collate = msoTrue
.OutputType = ppPrintOutputSlides
.PrintHiddenSlides = msoTrue
.PrintColorType = ppPrintBlackAndWhite
.FitToPage = msoFalse
.FrameSlides = msoFalse
.ActivePrinter = "hp LaserJet 1000"
' make this true if it fails to print accurately
.PrintInBackground = False
End With
oPPT.PrintOut
oPPT.Close
Set oPPT = Nothing
SlideShowWindows(1).Activate
End Sub
 
Garbo,
Make sure that the line below appears in the code window as a single line,
OE will probably introduce line breaks since I am posting plain text format.

Set oPPT = Presentations.Open(FileName:="C:\z_working\Trial_1.ppt",
ReadOnly:=msoFalse, WithWindow:=False)


--
Regards,
Shyam Pillai

Image Importer Wizard: http://skp.mvps.org/iiw.htm


Have you ensured that the entire
 
Hi Shyam,

I'm still getting the error.

Also, if I want to have it print out 3 different files, can I just list 3
filenames separated by a comma or do I have to run 3 procedures?

Thanks again.
 
Hi Shyam,

I'm still getting the error.

Also, if I want to have it print out 3 different files, can I just list 3
filenames separated by a comma or do I have to run 3 procedures?

Thanks again.
 
You can change the code I sent to accept a filename as parameter and call it
3 times.
'----------------------------------------------------------------------
'Usage:
Sub PrintAll()
Call PrintPresentation("C:\Presentation1.ppt")
Call PrintPresentation("C:\Presentation2.ppt")
Call PrintPresentation("C:\Presentation3.ppt")
End Sub

Sub PrintPresentation(Filename As String)
Dim oPPT As Presentation
Set oPPT = Presentations.Open(Filename:=Filename, _
ReadOnly:=msoFalse, _
WithWindow:=False)
With oPPT.PrintOptions
.RangeType = ppPrintAll
.NumberOfCopies = 1
.Collate = msoTrue
.OutputType = ppPrintOutputSlides
.PrintHiddenSlides = msoTrue
.PrintColorType = ppPrintBlackAndWhite
.FitToPage = msoFalse
.FrameSlides = msoFalse
.ActivePrinter = "hp LaserJet 1000"
' make this true if it fails to print accurately
.PrintInBackground = False
End With
oPPT.PrintOut
oPPT.Close
Set oPPT = Nothing
SlideShowWindows(1).Activate
End Sub
'----------------------------------------------------------------------
 
Back
Top