Changing ActivePresentation

R

Roland Leisch

Hello!

I have a very strange problem:

I try to change the active window (so change are applied to the right
window if several windows are open) and therefore I wrote a method which
searches for a special custom property and if it finds the needed one
this presentation is activated (at last it should be!). The problem now
is, that I cannont activate the presentations since Windows - Count is 0
and I get an exception.

Can anybody give me a hint where the problem could be? My main problem
is that I cant understand, why Windows collection can be 0 (I thought
that at least one window has to be opened)?

Im using a Java-COM bridge to integrate Powerpoint in an ole container
within my Java application.



Thanks in advance!


Source:
((_PresentationImpl) presentations.item(new
Variant(1))).getWindows().item(new Int(1)).activate();

I thought that this piece of code should work alsways since there has
always to be a least one presentation and one window but there is an
exception thrown in getWindows since count is zero?!?
 
S

Steve Rindsberg

Hello!

I have a very strange problem:

I try to change the active window (so change are applied to the right
window if several windows are open) and therefore I wrote a method which
searches for a special custom property and if it finds the needed one
this presentation is activated (at last it should be!). The problem now
is, that I cannont activate the presentations since Windows - Count is 0
and I get an exception.

Can anybody give me a hint where the problem could be? My main problem
is that I cant understand, why Windows collection can be 0 (I thought
that at least one window has to be opened)?

Im using a Java-COM bridge to integrate Powerpoint in an ole container
within my Java application.

Thanks in advance!

Source:
((_PresentationImpl) presentations.item(new
Variant(1))).getWindows().item(new Int(1)).activate();

I thought that this piece of code should work alsways since there has
always to be a least one presentation and one window but there is an
exception thrown in getWindows since count is zero?!?

Unless other code forces it, there doesn't have to be at least one
presentation. Might that be the problem?
 
R

Roland Leisch

Unless other code forces it, there doesn't have to be at least one
presentation. Might that be the problem?

Hello!

Thanks for yyour answer but Im sorry I didnt understand it. My Problem
is that if I start 2 instances of my application (each one contains an
ole container with and powerpoint presentation) only the last started
instance reacts to any commands. So I want to activate the first
instance to be able to exectue methods on this one.

So I wrote a method which identifies the right instance (ole container
with presentation) and now I have to activate this one. But that doesnt
work since Windows-Count is zero and I cant execute activate method!

Thanks in advance!
 
S

Steve Rindsberg

Hello!

Thanks for yyour answer but Im sorry I didnt understand it.

Hi Roland,

No worries. I'm probably misunderstanding your question too. ;-)
But I was responding to this:

=========
Source:
((_PresentationImpl) presentations.item(new
Variant(1))).getWindows().item(new Int(1)).activate();

I thought that this piece of code should work alsways since there has
always to be a least one presentation and one window but there is an
exception thrown in getWindows since count is zero?!?
============

I'm probably mistaken, but it looks like you're referencing

Presentions.Item(some_number)

But if there are no presentations open, there can be no
Presentations.Item(anything)




My Problem
 
R

Roland Leisch

I'm probably mistaken, but it looks like you're referencing
Presentions.Item(some_number)

But if there are no presentations open, there can be no
Presentations.Item(anything)

Ok - now I understand what you mean! But I open a presentation
programatically and it is displayed in the ole container and it is NOT
closed - so I thought Windows-Count has alwayys to be at least 1 until I
close the presentation. Nevertheless the Windows-Count is still zero.

The very strange thing is that this behavior only occours if I open a
second ole contianer containing a powerpoint presentation. With only one
ole container everything works fine!
 
S

Steve Rindsberg

Ok - now I understand what you mean! But I open a presentation
programatically and it is displayed in the ole container and it is NOT
closed - so I thought Windows-Count has alwayys to be at least 1 until I
close the presentation. Nevertheless the Windows-Count is still zero.

The very strange thing is that this behavior only occours if I open a
second ole contianer containing a powerpoint presentation. With only one
ole container everything works fine!

Hmmm. I've only played briefly with PPT shows in an OLE container, but a
couple things strike me as worth looking at:

While the container isn't activated, there wouldn't be any instance of PPT, so
any reference to a PPT object would throw an error. That's probably obvious to
you, so pardon my mentioning it. ;-)

But another point: PowerPoint is a single-instance application. You can't
have two copies of the same version running at once. How that affects what
happens to presentations in an OLE container, I don't know, but .... who
knows, maybe it's relevant?
 
R

Roland Leisch

While the container isn't activated, there wouldn't be any instance
of PPT, so
any reference to a PPT object would throw an error. That's probably obvious to
you, so pardon my mentioning it. ;-)

Hmm.. the strange thing is that Windows-Count first is 1 and only after
I open a second instance of my application containing an ole container
Windows-Count is 0.

But another point: PowerPoint is a single-instance application. You can't
have two copies of the same version running at once. How that affects what
happens to presentations in an OLE container, I don't know, but .... who
knows, maybe it's relevant?

Only one instance of powerpoint.exe is in memory (at least taskmamager
tells me that) and presentations-collection contains both presentations.

So everything is quite unclear!
 
R

Roland Leisch

Hello!

I have posted the problem before but there were some misunderstanding so
I will post again:

I have an application which uses an ole container to display an excel
workbook. In my application I have a menubar in which I can change Zoom
settings for the contained workbook (since I prohibited any interaction
on the workbook itself as I want it only to be displayed and not be
changed in any way).

If I start my application I can change the zoom settings without any
problems.

But if a start my application a second time (with an other workbook) Im
not able to change any settings in the first workbook (I can click on my
entries but nothing happens).

So I tried to implement a workaround: I add custom document properties
which allow me to identify the open workbooks. I iterate all workbooks
and if I find the right workbook I call workbook.activate(lcid).

The very strange thing is that this works only if one instance of my
application is open - if a second instance is running I get: COM object
method returns error code: 0x800A03EC and only the last started instance
reacts - the first instance gives me the 0x800A03EC error.

Has anybody here got an idea where the problem could be?

Thanks in advance!
 
R

Roland Leisch

Steve said:
THAT certainly sums it up well. <g>

Here's hoping somebody else has an idea that'll help. I'm fresh out.

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================


I found a workaround and until now it works:

Whenever I want to activate a file in an ole container I call
OleContainer.doVerb(SHOW) and everything is fine!
 
S

Steve Rindsberg

I found a workaround and until now it works:

Whenever I want to activate a file in an ole container I call
OleContainer.doVerb(SHOW) and everything is fine!

Roland, thanks for posting back with that. I'm sure it'll save somebody else
hours of work later.
 

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