Display PowerPoint presentation on secondary screen

J

Jakob Lithner

I have managed to automate PowerPoint fairly well.
I create presentation and set slide content from a Windows Forms application.
The idea is to have a database with songs and on demand search songs and
display on projector by switching content from the application.
Everything works fine, the presentation works the way I want it.

The only missing piece is that I also want to decide what display to hold
the presentation. There is no use creating the application if all content is
displayed on the primary screen.

How can I ask the OS for Screen collection and decide which one to use for
presentation?

Inside PowerPoint 2007 there is a Presentation Configuration setting that
decides what screen to use for the presentation.
But I can not find it in the automation model !!!!

I can move the slideshow window manually to the second screen and maximize
it everytime I launch the application. But this is not really elegant for end
users. And with this approach I still don't get rid of the Window borders:
PowerPoint Form heading and scroll bars.
 
J

Jakob Lithner

Full screen mode is resolved.
Very easy, I just missed it.
Setting ShowTypeSpeaker made the difference:
var settings = presentation.SlideShowSettings;
settings.ShowType = PpSlideShowType.ppShowTypeSpeaker;


I am still eager to get hints on how to move presentation to display of my
choice ....
 
T

Tim Li - MSFT

Hello Jakob,

As you mentioned, there's no API provided in PowerPoint Object Model to set
which screen to display the presentation, but while I'm using Process
Monitor to monitor this process, I've found that if we change the display
screen through the PowerPoint UI it actually changed a registry key which
is,
HKCU\Software\Microsoft\Office\12.0\PowerPoint\Options\DisplayMonitor

After I change the above value to "\\.\DISPLAY2\Monitor0" via codes,
PowerPoint will use the second monitor to display the presentation.

Thanks.

Best regards,
Tim Li
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).
 
J

Jakob Lithner

Thanks for your suggestion but I am nor really a friend of editing the
registry of my clients machines manually. In an update to PowerPoint this key
might very well change and then everything is messed up.

One other idea I had was to use the hWnd handle in some way. The object
model exposes the handle of the SlideShowWindow. Can this be helpful?
 
S

Steve Rindsberg

Jakob Lithner said:
Thanks for your suggestion but I am nor really a friend of editing the
registry of my clients machines manually. In an update to PowerPoint this key
might very well change and then everything is messed up.

One other idea I had was to use the hWnd handle in some way. The object
model exposes the handle of the SlideShowWindow. Can this be helpful?

Tim's suggestion is interesting but keep in mind that PPT typically reads its
registry entries on startup and from then on maintains the values internally.

In other words, if you change the registry values while the app is open, it has
no effect, and usually gets overwritten when the app quits.

However ...

Sub MoveMe()
Dim LeftOffset as Single
' Not sure exactly what the correct value should be but
' on my system at 1400 x 1050 x 2 monitors I used
LeftOffset = 1400 / 1.33
With SlideShowWindows(1)
.Left = LeftOffset
End Sub

There are Win APIs that will give you the screen width
 
J

Jakob Lithner

Yes I found the Screen collection and can read the properties.
But they are not of much help.

I understand the LeftOffset and tried it, but everything depends on what
Display is set in PowerPoint as the default for presentations. If I can't
detect that, it is meaningless to set a LeftOffset.

Actually I will probably need to give an instruction to the users to first
open PowerPoint and set the display there. The automated presentation from my
application will then default to the same display.

But I am not satisfied .....
I must be possible since I tried other software that offers the equivalent
combobox with displays to choose from.
 
T

Tim Li - MSFT

Hello,
its registry entries on startup and from then on maintains the values
internally.In other words, if you change the registry values while the app
is open, it has no effect, and usually gets overwritten when the app quits.


To (e-mail address removed),
This registry key is set by PowerPoint itself when user change options
manually in the application. That is to say, we do not need to restart
PowerPoint to make it effect. It works on fly.

To Jakob,

Please try the following codes,
Imports PowerPoint = Microsoft.Office.Interop.PowerPoint
Imports Microsoft.Win32

Module Module1
Dim app As PowerPoint.Application
Sub Main()
app = New PowerPoint.Application()
app.Visible = True
app.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTrue)
Dim customLayout As PowerPoint.CustomLayout = _
app.ActivePresentation.SlideMaster.CustomLayouts.Item( _
PowerPoint.PpSlideLayout.ppLayoutText)
app.ActivePresentation.Slides.AddSlide(1, customLayout)
WriteToRegistry(RegistryHive.CurrentUser,
"Software\Microsoft\Office\12.0\PowerPoint\Options", "DisplayMonitor",
"\\.\DISPLAY2\Monitor0")
app.ActivePresentation.SlideShowSettings.Run()
WriteToRegistry(RegistryHive.CurrentUser,
"Software\Microsoft\Office\12.0\PowerPoint\Options", "DisplayMonitor",
"\\.\DISPLAY1")
End Sub

Function WriteToRegistry(ByVal _
ParentKeyHive As RegistryHive, _
ByVal SubKeyName As String, _
ByVal ValueName As String, _
ByVal Value As Object) As Boolean
Dim objSubKey As RegistryKey
Dim objParentKey As RegistryKey
Dim bAns As Boolean
Try
objParentKey = Registry.CurrentUser 'Default
Select Case ParentKeyHive
Case RegistryHive.ClassesRoot
objParentKey = Registry.ClassesRoot
Case RegistryHive.CurrentConfig
objParentKey = Registry.CurrentConfig
Case RegistryHive.CurrentUser
objParentKey = Registry.CurrentUser
Case RegistryHive.DynData
objParentKey = Registry.DynData
Case RegistryHive.LocalMachine
objParentKey = Registry.LocalMachine
Case RegistryHive.PerformanceData
objParentKey = Registry.PerformanceData
Case RegistryHive.Users
objParentKey = Registry.Users
End Select
'Open
objSubKey = objParentKey.OpenSubKey(SubKeyName, True)
'create if doesn't exist
If objSubKey Is Nothing Then
objSubKey = objParentKey.CreateSubKey(SubKeyName)
End If
objSubKey.SetValue(ValueName, Value)
bAns = True
Catch ex As Exception
bAns = False
End Try
Return True
End Function

End Module

My opinion is summarized below:
1. We do not need to change the key manually. Actually it is done through
codes.
2. We can restore the registry key to default value after the automation.
It does not affect the customer machine because PowerPoint also changes the
registry key when you set the option in the application manually.
3. Every API could be changed in the new update, that should not be our
main concern. And in my opinion, this key is not likely to be changed in
future version.

Please note this is the easiest way to achieve your objective. Please test
my codes and let me know if it works. Any future support needed, please
feel free to update here. Have a nice day!


Best regards,
Tim Li
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).
 
J

Jakob Lithner

OK .... :)

I tried this approach and it works fine.
If you say I can trust the registry, then I go this way.
 
S

Steve Rindsberg

To (e-mail address removed),
This registry key is set by PowerPoint itself when user change options
manually in the application. That is to say, we do not need to restart
PowerPoint to make it effect. It works on fly.

Thanks for the correction, Tim, and the extra information. This is good news.
 

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