• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Printing PPT with VB ***please help***

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

jmh547

Member
Joined
Jul 26, 2005
My code below differentiates between an excel file and ppt file. The excel portion works fine, however, I am trying to figure out how to print the ppt while it is hidden. Anytime I touch the "app.Visible" either remove it, set it to "False," or move it I get the following error:

Code:
Presentations.Open:Invalid Request. The PowerPoint Frame window does not exist.

What am I doing wrong :bang head

Code:
Sub Print_File(File As String, n As Integer)
    Dim app As Object
               
    If InStr(1, File, "xls") <> 0 Then
        Set app = CreateObject("Excel.Application")
        app.workbooks.Open File
        app.Visible = False
        app.ActiveWindow.SelectedSheets.PrintOut Copies:=n
        app.workbooks.Close
    ElseIf InStr(1, File, "ppt") <> 0 Then
        Set app = CreateObject("PowerPoint.Application")
        app.Visible = True
        app.Presentations.Open (File)
        app.ActivePresentation.PrintOut Copies:=n
        app.ActivePresentation.Close
        app.Quit
    Else
        MsgBox "File Type Not Valid", vbCritical, "ERROR"
    End If
        
End Sub
 
I was reading about Powerpoint and it's a requirement to have it visible. That doesn't mean it doesn't have to be hidden. Leave it as visible, but minimize it:

Code:
PowerPoint.Application.WindowState = ppWindowMinimized
 
Back