how to set the slideshow monitor programmatically

Hi experts,
Now,I'm using dual-monitor system (separated-dualview mode). Then, I am creating an application in Delphi 7: to show a ppt file in which the control panel is in primary monitor and the slide show is in secondary monitor. The problem is: to change the slideshow on secondary monitor  I must setup manually within PowerPoint's menus (Slide Show | Set up Show | set Display slide show on: secondary monitor). How to set up this programmatically with Delphi 7?
I use TPowerPointApplication (server pallete) component.
Thank you
LVL 1
amagabarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Emmanuel PASQUIERFreelance Project ManagerCommented:
there is no option for that in the PPT object model.

What about using the OLE container in a form as I stated in a former question ? You could then show this form in the screen you want. Here is a function to show a form in whatever monitor (1 for the 1st, 2 for second, and 0 for the whole desktop area (that spans across all monitors) :
procedure TForm1.FullScreenToMonitor(Scr:Integer=1);
begin
// Put the form in the upper left corner of the 2nd monitor
// if more then one monitor is present.
 WindowState:=wsNormal;
if (Scr>=1) And (Scr<=Screen.MonitorCount) then
 begin
  Left := Screen.Monitors[Scr-1].Left;
  Top := Screen.Monitors[Scr-1].Top;
  Width:= Screen.Monitors[Scr-1].Width;
  Height:= Screen.Monitors[Scr-1].Height;
  WindowState:=wsMaximized;
 end else
 begin
  Left:=Screen.DesktopLeft;
  Top:=Screen.DesktopTop;
  Width:=Screen.DesktopWidth;
  Height:=Screen.DesktopHeight;
 end;
end;

Open in new window

0
amagabarAuthor Commented:
Ok thank you epasquier, but unfortunately, until now I have not been able to utilize TOLEContainer. When I apply it show a ppt file, only the first slide that appear. This is the code:

procedure TForm1.SpdBtnOLEClick(Sender: TObject);
begin
 if (OpenDialog1.Execute) then
 begin
  olecontainer1.CreateObjectFromFile(Opendialog1.FileName,false);
  olecontainer1.Run;
 end;
end;

Please help  me to show a way how to control the olecontainer (prev,next, etc) ?
Tq.
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
I think you can call the Next method
http://msdn.microsoft.com/en-us/library/bb265428%28v=office.12%29.aspx

add a button and call it when clicked for example :
olecontainer.OleObject.SlideShowWindow.View.Next;

I tested it, but it opens a new windows... M$ sucks... But you can control this window position & size. I suppose you can do as well with TPowerPointApplication, the only difference would be in setting the SlideShow OLEVariant

procedure TForm1.PPTFullScreenToMonitor(Scr:Integer=1);
Var
 SlideShow:OLEVariant;
begin
 SlideShow:=olecontainer.OleObject.SlideShowWindow;
 if (Scr>=1) And (Scr<=Screen.MonitorCount) then
  begin
   SlideShow.Left := Screen.Monitors[Scr-1].Left;
   SlideShow.Top := Screen.Monitors[Scr-1].Top;
   SlideShow.Width:= Screen.Monitors[Scr-1].Width;
   SlideShow.Height:= Screen.Monitors[Scr-1].Height;
 end; else
 begin
  SlideShow.Left:=Screen.DesktopLeft;
  SlideShow.Top:=Screen.DesktopTop;
  SlideShow.Width:=Screen.DesktopWidth;
  SlideShow.Height:=Screen.DesktopHeight;
 end;
end;

Open in new window

0
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

amagabarAuthor Commented:
Still nor work. Here is the chunk of my code:

procedure TForm1.Button1Click(Sender: TObject);
begin
 if OpenDialog1.Execute then
 begin
  Olecontainer1.CreateObjectFromFile(OpenDialog1.FileName, false);
  OleContainer1.Run;
  OleContainer1.AutoActivate := aaGetFocus;
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  olecontainer1.OleObject.SlideShowWindow.View.Next;
end;

when I run it, and click the Button3, then raising an error with message::

'There is currently no slide show view for this presentation'


0
Emmanuel PASQUIERFreelance Project ManagerCommented:
You need to 'run' the slideshow before having access to the SlideShowWindow
Var
 PPTObject,SlideShow:OLEVariant;

procedure TForm1.Button1Click(Sender: TObject);
begin
 if OpenDialog1.Execute then
 begin
  Olecontainer1.CreateObjectFromFile(OpenDialog1.FileName, false);
  OleContainer1.Run; // start the OLE app (PPT)
  OleContainer1.AutoActivate := aaGetFocus;
  PPTObject:=OleContainer1.OleObject;
  PPTObject.SlideShowSettings.Run; // start the PPT slideshow
  SlideShow:=olecontainer.OleObject.SlideShowWindow;
 end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 if Not VarIsEmpty(SlideShow) Then SlideShow.View.Next;
end;

Open in new window

0
Emmanuel PASQUIERFreelance Project ManagerCommented:
little changes :

- AutoActivate is probably useless
- since I declared PPTObject and assigned it to the OleObject, I should use it when getting the SlideShow reference

procedure TForm1.Button1Click(Sender: TObject);
begin
 if OpenDialog1.Execute then
 begin
  Olecontainer1.CreateObjectFromFile(OpenDialog1.FileName, false);
  OleContainer1.Run; // start the OLE app (PPT)
  PPTObject:=OleContainer1.OleObject;
  PPTObject.SlideShowSettings.Run; // start the PPT slideshow
  SlideShow:=PPTObject.SlideShowWindow;
 end;
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amagabarAuthor Commented:
Finally.. I can... Ok  thank you epasquier:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.