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:
What am I doing wrong
Code:
Presentations.Open:Invalid Request. The PowerPoint Frame window does not exist.
What am I doing wrong
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