hidden windows

camg12

Registered User.
Local time
Today, 00:49
Joined
Jan 5, 2010
Messages
18
I am using this vba code to open a powerpoint file and update the links. Right now I'm having to make the object visible but I want to be able to run this in the background and hidden to users. Is this possible?

Code:
Public Function OpenPPT()
Dim PPObj As Object
Set PPObj = CreateObject("Powerpoint.Application")
PPObj.Visible = True
PPObj.Presentations.Open FileName:="C:\test.pptx"
PPObj.ActivePresentation.UpdateLinks
PPObj.ActivePresentation.Save
 
PPObj.Quit

End Function
 
What happens when you run it as false?

Code:
[B]PPObj.Visible = False[/B]
 
I get a run-time error :

Application.Visible : Invalid request. Hiding the application window is not allowed.
 
You need to open the presentation itself without a window.
Something like the following would work:
Code:
Dim PPObj as Powerpoint.Application
Dim oPPTPres as PowerPoint.Presentation
Dim sFileName as String
 
Set PPObj = New PowerPoint.Application
sFileName = "C:\test.pptx"
Set oPPTPres = PPObj.Presentations.Open(sFileName, WithWindow:=msoFalse)
 
' Do your stuff
Don't use the .Select method or do anything that references the document window, activewindow etc
 
Thanks that works perfect. When I try this on an excel workbook though I get the error name argument not found (WithWindow). Would I use something different?
 
Make sure you have a reference set to Microsoft Office
 
I have the reference set to Microsoft Office as well as Microsoft Excel but am still getting the error.
 

Users who are viewing this thread

Back
Top Bottom