Embedded PowerPoint in WindowsForms ?

J

Jakob Lithner

I would like to create a WindowsForms application that displays songtexts on
a projector screen.

The idea is to have a laptop computer running the application and connect a
projector that will display texts on SecondScreen.
I think PowerPoint would be a good mechanism to create the projected
pictures since that will help resizing, providing nice backgrounds, etc.

In the application GUI I would like to provide possibility to either choose
song texts from internal database and generate PowerPoint content on the fly,
or choose prepared external PowerPoint file.

I saw an application doing something similar and I liked the idea but I want
to extend it further.

I found examples on how to automate PowerPoint application.
I have referenced PowerPoint.Interop and Office.Core namespaces and have
been playing around a little. But I realize it is easy to get lost in the
object model. So I think I need some more advice:

1) Is it possible to display PowerPoint content in a slideview control, like
in PowerPoint normal GUI?

2) Should client have full version of PowerPoint or would PowerPoint Viewer
be enough?

3) Does anyone know a good place to get started?
 
L

Linda Liu[MSFT]

Hi Jaklithn,

I finished reading some materials about automating PowerPoint in .NET
applications. For example the following KB article introduces how to use
automation to create and show a PowerPoint presentation in VB.NET 2003 or
2003:
http://support.microsoft.com/default.aspx/kb/303717

However, this will show the PowerPoint presentation stand alone, i.e. when
the PowerPoint presentation is showing, it isn't embedded in a WinForm.

To embed a PowerPoint presentation in a WinForm, you may use the ActiveX
control Dsoframer.ocx. Visit the following link for more information on
this ActiveX control:
http://support.microsoft.com/kb/311765
1) Is it possible to display PowerPoint content in a slideview control,
like in PowerPoint normal GUI?

Could you please tell me what the "slideview contro" is?
As I have mentioned above, you can display PowerPoint content in a
Dsoframer ActiveX control.
2) Should client have full version of PowerPoint or would PowerPoint
Viewer be enough?

The client machine should have full version of PowerPoint installed. As for
PowerPoint Viewer, it is an application that can open/view various versions
of PPT documents but it hasn't function to edit PPT documents. Not only
PowerPoint automation but also the Dsoframer ActiveX control work on the
fundamental of full version of PowerPoint.
3) Does anyone know a good place to get started?

I suggest that you use the Dsoframer ActiveX control to embed PPT in your
application. Visit the link to get started:
http://support.microsoft.com/kb/311765

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
J

Jakob Lithner

Hi Linda!

Thanks for answering!

And thanks also for sending me a reminder on email.
I did check the box for getting notifiers and was disappointed to have no
answer.
Obviously it doesn't work all the time ....

The ActiveX control surely looks very promising.
I will give it a try as soon as possible.

One minor question until then:
The internal ActiveX container to review the PowerPoint file is just for
discerning what to display on the projector. So I guess I will have two
instances of PowerPoint going parallell.
Is it possible to decide what screen to point the output of the "external"
PowerPoint instance? I found the .Net Framework concept of PrimaryScreen and
SecondaryScreen, but I did not find a mechanism to direct the output of
PowerPoint.

I tried the online example of creating a PowerPoint on the fly from code and
showing it, but it never showed up visible. Maybe that is because PowerPoint
by default will direct output to SecondaryScreen and I had only one screen
wired at that time?
 
L

Linda Liu[MSFT]

Hi Jakob,

Thank you for your reply!

I performed a test on the sample code provided by the KB
article(http://support.microsoft.com/default.aspx/kb/303717). My computer
has only one screen. When I run the application and click the button on the
form, I see PowerPoint is launched and slide show is run.

The Screen class in .NET Framework represents a display device or multiple
display devices on a single system. We can retrieve an array of all the
screens connected to the system by calling the AllScreens property of the
Screen class. To show a form in a screen, set the Location of the form to
the location of the screen in qestion.

However, I don't see we can set the location of the PowerPoint application
because the PowerPoint.Application doesn't have a Location property.

You may have a try on another machine to see if the problem still exists.


Sincerely,
Linda Liu
Microsoft Online Community Support
 
J

Jakob Lithner

OK, I will try to find a another machine where I can install development
environment .....

I had a try with the other article to get the PowerPoint show up in the
dsoframe.
There were examples, but no instructions on how to incorporate it in your
own existing solution. I use C# in VS2008 and tried the following:

I added dsoframer.ocx to the Lib directory of the solution.
I added it as a COM component to the ToolBox (which also added references to
DSOFramer and AxDSOFramer).

Then I dragged the control to a form and tried the following code:

// Open existing file
string fileName = @"C:\ArbetsDokument\Projekt\SongList\Test.ppt";
myAxFramerControl.Open(fileName);

// Connect to the presentation and automate it
var pres = (Presentation) myAxFramerControl.ActiveDocument;
pres.Slides[1].Shapes[1].TextFrame.TextRange.Text = "Jakob was here";

When the form is opened I get the following error:
The class is not registered (Exception from HRESULT: 0x80040154
(REGDB_E_CLASSNOTREG))

This happens already in the designer code line
((System.ComponentModel.ISupportInitialize)(this.myAxFramerControl)).EndInit();

I thought it might need a registration so I went to command prompt and ran
regsvr32 on the ocx, but it was not successful.

Something I missed?
 
L

Linda Liu[MSFT]

Hi Jakob,

Thank you for your prompt response!

Firstly, an AciveX control needs to be registered before it can be used
(use regsvr32 command to register it).

As for this dsoframer.ocx, after we download and install the Microsoft
Developer Support Office Framer Control 1.3
sample(http://www.microsoft.com/downloads/details.aspx?FamilyId=CE2CA4FD-216
9-4FAC-82AF-770AA9B60D77&displaylang=en), the dsoframer.ocx is registered.

I have tested this and all works well.

Can you register the dsoframer.ocx with the regsvr32 command successfully?

Sincerely,
Linda Liu
Microsoft Online Community Support
 
J

Jakob Lithner

I thought registration might be an issue.
I already tried to unregister the ocx from the install directory just to be
sure I don't have duplets in registry. But it was not possible to do.

The ocx I added to Toolbox controls was the one I had added to my solution
Lib directory. My idea was to have all external dependencies in one place so
I don't erase them later by mistake.
Maybe I should have referred to the original location instead?
 
L

Linda Liu[MSFT]

Hi Jakob,

Thank you for your reply!

Please log on with Administrator account to register/unregister the ActiveX
control. If you're using Windows Vista, you need to elevate the cmd.exe
with Administrator privilege, i.e. right-click the cmd.exe and choose "Run
as administrator".

It doesn't matter where the ActiveX control is located on the development
machine. When you add the ActiveX control to your form, VS will generate
interop assemblies to wrap the ActiveX control. When you run the
application that uses the ActiveX control on a client machine, the ActiveX
control is also required to exist and be registered on the client machine.
But it doesn't matter where the ActiveX control is located on the client
machine.

Hope this helps.
Please try my suggestion. If you have any question, please feel free to let
me know.

Sincerely,
Linda Liu
Microsoft Online Community Support
 
E

Elza Thomas

hi..

I tried using dsoframer within my VC++ application.
Once I open a .ppt file it opens in edit mode and not in slideshow mode.

Can anyone please help as to how I can get it default to slideshow mode?

Regards,
Elza
 
L

Linda Liu[MSFT]

Hi Elza,

Based on my research, the dsoframer ActivX control doesn't support showing
a .ppt file in slideshow mode so far. You may instead use the WebBrowser
control to show the .ppt file in slideshow mode.

Sincerely,
Linda Liu
Microsoft Online Community Support
 
J

Jakob Lithner

Thanks for all efforts Linda!

The registration problem of the ocx was partly solved by the Administrator
privileges. Now I succeeded to register the dsoframer.ocx
But the same error turned up when I launched my code :(
I did remove the control, removed the toolbox shortcut, unregistered
the ocx and tried the whole thing over again but still with no success.
Maybe it is a problem that I use Vista 64-bit OS?

After reading your reply to Elza I decided to treat this track as a dead end.
If I can not display presentations in the control I don't have that much use
of it anyhow.

It would be nice to display the current slide in a preview control in the
Windows Form, but it is not necessary for the functionality.
Much more crucial for my application is the first idea of automating
external PowerPoint and display content (created on the fly) on external
monitor.

I followed the example given in
http://support.microsoft.com/default.aspx/kb/303717
I succeded in creating PowerPoint files but not displaying them.
It crashed every time I hit the SlideShowSettings Run command.
After days of struggling i found out this might also be caused by the Vista
64-bit environment.
I then eployed the application to my laptop Vista 32-bit environment.
It made a difference in that I was able to launch the Run but then I got
stuck anyhow. It is very hard to debug in deployment mode ......
I set loads of MessageBox dumps after every command to evaluate how far I got
and what values all objects had.

My current workaround to handle the situation is to just create a complete
slideshow for all songs in advance and then manually run it in PowerPoint
slideshow environment.
But this has major drawbacks as the whole sequence of songs must be set
statically
and I am not open to ad hoc choosing of songs.
A rough estimate of the complete song list would be ~1000 songs with each
2-8 verses. On a typical occasion 10 songs are used. It is possible to choose
most of them in advance, but it is a strong wish to add songs on the fly.

My suggested setup is this:
1) Open a template with three slides: Initial logo slide, black slide for
pausing and text slide
2) Open the presentation as a SlideShow and by user interaction decide which
slide to display
3) On user command recreate the content of the text slide to display the
current song

The suggestion is to have a presentation going live and on the fly switch
content of the third slide. All automation should be controlled from a
Windows Forms GUI.

I tried this code:
1: presentation.SlideShowSettings.AdvanceMode =
PpSlideShowAdvanceMode.ppSlideShowManualAdvance;
2: presentation.SlideShowSettings.ShowType = PpSlideShowType.ppShowTypeWindow;
3: presentation.SlideShowSettings.StartingSlide = 1;
4: var slideShowWindow = presentation.SlideShowSettings.Run();
5: var slideShowView = slideShowWindow.View;
6: slideShowView.GotoSlide(3, MsoTriState.msoFalse);
7: MessageBox.Show(string.Format("Position = {0}" ,
slideShowView.CurrentShowPosition));

When hitting the fifth line I get this Error: "SlideShowWindow (unknown
member) : Object does not exist."
I guess I misunderstood how to handle the slideshow object.
What is the command to switch slide in a SlideShow?
 
L

Linda Liu[MSFT]

Hi Jakob,

Thank you for your reply!
What is the command to switch slide in a SlideShow?

Your way to switch slide in a SlideShow is correct, i.e. call the
SlideShowWindow.View.GotoSlide method. I performed a test on this method in
the sample project provided by the KB article and succeeded in switching to
the specified slide.

The code snippet in my test project is as follows:

objSSS = objPres.SlideShowSettings;
objSSS.RangeType =
Microsoft.Office.Interop.PowerPoint.PpSlideShowRangeType.ppShowSlideRange;
objSSS.StartingSlide = 1;
objSSS.EndingSlide = 3;
objSSS.Run().View.GotoSlide(3,MsoTriState.msoTrue);

However, when the slide show runs, the first slide is always displayed
firstly and then the third slide is shown. A solution to this problem is to
set the StartingSlide and EndingSlide properties of the SlideShowSettings
object to the specified slide index. For example:

objSSS = objPres.SlideShowSettings;
objSSS.RangeType =
Microsoft.Office.Interop.PowerPoint.PpSlideShowRangeType.ppShowSlideRange;
objSSS.StartingSlide = 3;
objSSS.EndingSlide = 3;
objSSS.Run();

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support
 
J

Jakob Lithner

Yesterday I detected by chance that the code line causing me trouble was the
StartingSlide line. When it was removed my example suddenly worked fine.

In your example I notice the addition of the RangeType property. When
RangeType is set to ppShowSlideRange the StartingSlide property does not
cause any trouble, which indicates that the default is not ppShowSlideRange.
 
L

Linda Liu[MSFT]

Hi Jakob,

Thank you for your prompt reply!

Is your problem solved now? If you have any question, please feel free to
let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support
 
J

Jakob Lithner

Problem is solved, and I am on the go exploring PowerPoint automation!
Thanks for your help Linda!

For others finding this thread:
Office Development section of MSDN Library is a very good reference!
 
L

Linda Liu[MSFT]

Hi Jakob,

Thanks for your response. I'm glad to hear that the problem is solved now.

If you have any other questions in the future, please don't hesitate to
contact us. It's always our pleasure to be of assistance!

Have a nice day.

Cheers,
Linda Liu
Microsoft Online Community Support
 
M

mark Lovelock

Has anyone got a copy of ActiveX Control DSOFramer.ocx as all the links
i have found go to a dead end.

I am trying to embed PowerPoint into a windows form but as i have seen
on most of the searches you need ActiveX Control DSOFramer.ocx to do
this.

Please any assistance would be appreciated.
 

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