Hide automated show creation

V

Vic

Hello,

I am trying to automate the creation of building the PPT file and I want to
hide the process. However, I can't seem to get rid of having to activate
the application object which cause a blank PPT screen to flash. The
"Unknown Member" seems to be what has to be identified but how?? Following
is the code with comments attached to what I've tried.

Thank you very much, Vic


Set oPwrpnt = CreateObject("Powerpoint.application")

' oPwrpnt.Visible = False <<=== This fails Application (unknown
member) : Invalid request. Hiding the application window is not allowed.
oPwrpnt.Activate <<== will flash a blank PPT screen
'oPwrpnt.WindowState = ppWindowMinimized <<== Fails if the above
is commented out

deffilename = App.Path & "\" & main.cboChartSelection &
"\MyTemplate.pptxm"

'following statement fails with the error: 'Presentations (unknown
member) : Invalid request. The PowerPoint Frame window does not exist.
' if oPwrpnt.Activate is commented out

Set OpwrPresent =
oPwrpnt.Presentations.Open(deffilename).Slides(1)

'Also the following fails with the same error as above
Set OpwrPresent = oPwrpnt.Presentations.Open(deffilename,
False).Slides(1)
 
V

Vic

Shyamm,

I had already tried that but it also fails with "following statement fails
with the error: 'Presentations (unknown member) : Invalid request. The
PowerPoint Frame window does not exist." if don't have oPwrpnt.Activate
included which causes the blank PPT screen to be flashed.


Vic
 
S

Shyam Pillai

Hello Vic,
My recommendation is that you spend some time reading up on the PowerPoint
object model rather that simply making edits to existing code without understanding
the underlying fundamentals.

1st: ".pptxm" is not an extension. It is either ".pptm" or ".pptx"
Correct this line: deffilename = App.Path & "\" & main.cboChartSelection
& "\MyTemplate.pptm"


2nd: Look up the help file for the Presentations.Open or Presentations.Open2007
method. Pass false for the WithWindow argument.

Examples:
Set OpwrPresent = oPwrpnt.Presentations.Open(deffilename, , , False).Slides(1)

or
Set OpwrPresent = oPwrpnt.Presentations.Open2007(deffilename, , , False).Slides(1)


Regards,
Shyam Pillai

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

Vic

Shyam,

I have been reading everything I can find on the subject and I am getting a
better understanding of the process but still a long way to go. I don't
know why suppressing the creation of a presentation should be so problematic
but it is. If I try to just minimize it, I have to activate it, and it
flashes a blank screen. The pptxm was a typo and I didn't realize what
these "m" files were utill the other day when I added some vba code to the
presentation file. I was careless and not paying close enough attention to
details and consequently made the typo.

OK that said, I almost have this thing working as it has completed the
creation of the slide with multiple graphs from the database but now when I
try to save the final slide it says there is no active presentation
(Application (unknown member) : Invalid request. There is no active
presentation.). The statement to save is "oPwrpnt.ActivePresentation.SaveAs
(CGFF_PPTFileName)". I open it with "Set OpwrPresent =
oPwrpnt.Presentations.Open(deffilename, , , False).Slides(1)".

So Shyam how do I save the completed slide if there is not an active
presentation?

Thanks,

Vic
 
S

Shyam Pillai

Since your PowerPoint window is hidden there is no ActivePresentation.
You need to reference the presentation you are opening so that you can save
that presentation later.

'Reference to the presentation
Dim oPres as PowerPoint.Presentation

Set oPres=oPwrpnt.Presentations.Open(deffilename, , , False)
Set OpwrPresent =oPres.Slides(1).

....

When you are ready to save use:


Call oPres.SaveAs (CGFF_PPTFileName).

Close the presentation and clear the refrence.

oPres.Close
Set oPres=Nothing

Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how
 

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