How to achieve asyncronous i/o and invocation while automating ppt

G

Guest

Hi,
I have a problem with powerpoints saveas during automation (from VB.NET
atm). It seems to me that whenever I issue commands like saveas the ppt app
acts like a blocking proxy, disabling other threads to invoke methods until
the previous invoke (tested with saveas method) is done. I've got 1 reply in
the forums, claiming this behaivior is as expected if i use 1 ppt app for all
presentations. Would it help if I'd use many. How can I achive this without
using multiple computers?

For details:

I'm using ppt app to save several ppts to html and to gif. Despite using the
app from separate c++ threads (in MTA) looking at my log it seems that
saveas is synchronized, meaning no other request to the ppt app is being
processed till the file is not saved. All my threads are waiting. Is this
really how Powerpoint application works, or maybe my harddisk is that slow?
If so, is there any workaround for achieving async i/o and/or invocation for
ppt app's methods?
Thanks,
Bitula
 
C

Chirag

Hi,

PowerPoint is a single instance app. So, even if you create multiple threads
in your application, they all get serialized at the external single ppt
instance. But you can run multiple instances if you invoke them through
different users on the machine. You can try the following in your app and
see if you succeed:
1. Create users on the machine.
2. Fill CoAuthIdentity with user information.
3. Use this in CoAuthInfo structure.
4. Use CoCreateInstanceEx() to start a PowerPoint instance and use the
CoAuthInfo structure in CoServerInfo.
5. This way, you should be able to create a PowerPoint instance for each
user that you created in step 1.
6. Once you are done with the processing, ensure that the users that you
created in step 1 are deleted.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
G

Guest

Hi,
Great! Thanks a lot for the info! It was very helpful! Could you tell me
wether I can do this stuff from VB .NET. Or other managed code? Or I need to
do this in unmanaged c++. Must I cocreate with coauthinfo the ppt app
directly or is it sufficient to cocreate the VB .NET dll com server from my
plain c++ dll, I mean will this indirection be recognizedc by VB's
CreateObject(). Lastly, can I create users and cocreate with the user in a
dll or I need to make an exe client? One more thing: im using PowerPoints
Copy and Paste functions quite frequently, so I need to synchronize these
code parts, however if I'll automate with different windows users, can I lift
the synclock from these code parts?
Thanks in advance!
Bitula
 
C

Chirag

I have a feeling that you are making this more complicated than what it
needs to be. Is there any specific reason you have synchronization
primitives around Copy and Paste? Before that, try to avoid using Copy/Paste
altogether. You can move slides around without copy/pasting - look at the
MoveTo() method on slide object.

For VB.Net dll and native C++ dll, I don't know the relationships between
them, why they both exist instead of only one, etc. So, won't be of much
help here until a lot of related details get cleared. As such, you can
pinvoke any Win32 call from .Net managed code so, you don't actually have to
have native C++ code.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
G

Guest

Thanks a lot. After you confirmed that it is possibele I found a way how to
achieve this in VB .NET. To contribute, I'll post the links I found:
http://www.codeproject.com/dotnet/addnewuser.asp?df=100&forumid=14622&exp=0&select=718275
and
http://www.codeguru.com/forum/archive/index.php/t-327056.html
for cocreateex. I guess this is how it need be done?
Latter looks complicated though still better than rewriting my vb code to c++.

As for other issues:
I use copy/paste because I need to copy slides from one presentation to an
other (destination will have less slides than the source), and as I see it
moveto() moves slides only within the same presentation. I needed to sync
them, because not doing so crashed the ppt app, I thought it must have been
because there is only 1 clipboard in windows and this caused the crash
because of using it simultenously from multiple threads, this is why I asked,
what will happen if used by different users: will windows allocate a separate
clipboard for each user? On the other hand I think that you are probably
right about solving this problem without copy paste and I am open to any
suggestions. One thing I devised is to load source ppt into memory and remove
uneeded slides, though I dont know wether this is the faster solution in case
of very few slides (which is the typical) like 2 of 40 and then I cant reuse
1 source for many dest replica which is also typical. I'm really curious
about what is the fastest way of moving slides across different presentations.

Conserning C++ dll, we need it, because we use it from a java application as
a native library, and AFAIK a VB .NET dll cannot be loaded this way, I read
somewhere that it does not have the needed entry points. This dll is
multithreaded because JNI cannot reenter same exported function until the
function runs. VB com server is being invoked through IDispatch, I did not
want to write the ppt automation (and other functional misc code) in c++,
because it would have been much more complicated and time consuming.

Your answers were very helpful so far. When can I press the "It was halpful
button), when last question was answered or at any time (I mean will the
button close the discussion).
 
Top