[2008] Display powerpoint slides on form and run slides from form
Please can someone point me to some code that will load powerpoint slides into a scrolling image container and allow me to control the presentation by double-clicking the slide image.
If powerpoint is not installed on end users machine can we use Powerpoint viewer and automate it by code ?
Re: [2008] Display powerpoint slides on form and run slides from form
If your end goal is simply to allow people to view PowerPoint slides, can you not point them to the freeware viewer MS provides, or bundle the installer in with your app?
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
I wouldn't have thought you could automate the viewer - it is a cut down version with (I suspect), the VBA and object model completely stripped down.
Why automate what is provided there though. What are you trying to accomplish with this part of your app?
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
The only way I can see you doing this programatically would be to open the file, loop through the sheets, perform a shreenshot on each and output this to a series of image container controls dynamically - this wouldn't be elegant, is prone to errors and would cause a terrible flicker on screen.
I've just been through the PowerPoint object model, and .Net/COM toolbox items and can't see anything there at all.
It is possible if you had VB6 still you could look at the ole control, but again I'd expect this would just show individual slides.
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
I have never seen this product, thanks. I am really only looking for bringing in ppt slides read-only into my form. Heavens - $599 is quite a lot.
Originally Posted by alex_read
The only way I can see you doing this programatically would be to open the file, loop through the sheets, perform a shreenshot on each and output this to a series of image container controls dynamically - this wouldn't be elegant, is prone to errors and would cause a terrible flicker on screen.
I Am interested in your other solution, though. Convert slides into images and display in a vertically scrolling container. I'm willing to risk the flicker.
Do you think you can help me with that ?
I do know that if you can get slideno(x) from the array of slides, you can pass it to powerpointviewer's commandline interface and have it display only that slide. It's at the bottom of the MS-page.
Re: [2008] Display powerpoint slides on form and run slides from form
Well you'd use something like this to enumerate the powerpoint slides and select each (show this individual slide on screen). Are you familiar with accessing office/PowerPoint libraries from .Net? If not goto the top of the Office forum on this site and Rob's got a section on it. This is VBA code but you'll need to qualify each call properly i.e. PowerPoint.Application.Presentations(1) etc.
Code:
If Not (ActivePresentation.Slides Is Nothing) Then
Dim currentSlide As Slide
For Each currentSlide In ActivePresentation.Slides
ActivePresentation.Slides(currentSlide).Select
Next
End If
For the final bit, you'd have maybe a panel control (is that in Windows forms - groupbox maybe [I'm a web developer]), then create image or picturebox controls at runtime. These are known as dynamic controls and there's a version of a label creation via code here: http://www.vbforums.com/showthread.p...namic+controls
Last edited by alex_read; Jun 12th, 2008 at 08:04 AM.
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
Thanks Alex. I have to operate under the pretext that end user may NOT have POwerpoint installed at their end.
So I need some way to :
* export ppt slides to image1, 2 etc without having to open an instance of PP :found something here on codeproject
* import images into container
* on image double click fire up powerpointviewer(slide(x))
Last edited by Xancholy; Jun 12th, 2008 at 08:29 AM.
Re: [2008] Display powerpoint slides on form and run slides from form
Well, you can try this. Edit: Removed additional attachment as this was written into the attachment within my other post further down this thread.
If you look at the main Dump method in that codeproject file, he's instanciating powerpoint and running the slideshow from the COM library included with his project. I honestly don't know whether that will have any use to you if your user hasn't even got the reader on.
I'd test this carefully on both a machine without powerpoint and on one with just the reader on it.
To run this, create a new Windows application project, then from the Project > Add References menu, navigate to the COM tab of the dialog which appears. Select the Microsoft PowerPoint x.x object library. Finally - edit the filename of the powerpoint file at the top of this file and it should run ok.
Last edited by alex_read; Jul 16th, 2008 at 06:57 AM.
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
Alex, thanks and sorry for my delay in replying. The problem with referencing Powerpoint is for eg: in my case I have PowerPOint9 & Office2000. I'm sure your code will work for end users who have >Office2000.
While I am still experimenting with your code, I still think I need to be able to export the powerpoint slides to images and then find a way to automate the viewer.
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop
Imports System.IO
Imports System.Runtime.InteropServices
Public Enum ExportImageType
JPG
BMP
PNG
GIF
End Enum
Public Class PowerPointExporter
Public Shared Sub ExportPresentation(ByVal fileName As String, ByVal outputPath As String, ByVal imageType As ExportImageType, ByVal width As Integer, ByVal height As Integer)
If Not File.Exists(fileName) Then
Throw New FileNotFoundException(fileName)
End If
If Not Directory.Exists(outputPath) Then
Throw New DirectoryNotFoundException(outputPath)
End If
Dim app As New PowerPoint.Application()
' app.Visible = MsoTriState.msoFalse
'for Office 2003
Dim presentation As PowerPoint.Presentation = _
app.Presentations.Open(fileName, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoTrue)
'for Office 2007
' Dim presentation As PowerPoint.Presentation = _
app.Presentations.Open2007(FileName:=fileName, ReadOnly:=MsoTriState.msoTrue, WithWindow:=MsoTriState.msoTrue)
For Each slide As PowerPoint.Slide In presentation.Slides
Dim name As String = IIf(slide.Name.Trim().Length = 0, slide.SlideIndex, slide.Name)
Dim outputFileName As String = Path.Combine(outputPath, name) & "." & imageType.ToString()
slide.Export(outputFileName, imageType.ToString(), width, height)
Marshal.ReleaseComObject(slide)
Next slide
Marshal.ReleaseComObject(presentation)
Marshal.ReleaseComObject(app)
End Sub
End Class
Sample usage:
Code:
Dim fileName As String = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Test.ppt")
PowerPointExporter.ExportPresentation(fileName, "c:\temp", ExportImageType.JPG, 1024, 768)
Last edited by Xancholy; Jun 16th, 2008 at 01:33 PM.
Re: [2008] Display powerpoint slides on form and run slides from form
If you knew that then why try to load a ppt in a form? You should only be loading pps or ppsx. It will all depend on how you are going to handle the user having PP or not. If you are going to have them download and install the viewer too then you can always depend on using the viewer regardless and show pps files. Use SetParent on the Viewer to nest it in a vb form.
You may also be export the ppt to a stand alone slide show by selecting the export to CD option and then distributing the supporting files
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Re: [2008] Display powerpoint slides on form and run slides from form
There may be some misconception here. ppt vs pps is not really the issue is it ? pps opens PP in play mode while ppt opens PP in edit mode.
My question is how to get ALL those slides to display onto a form. Sort of like powerpoint when it's in SlideSorter View.
Originally Posted by RobDog888
If you are going to have them download and install the viewer too then you can always depend on using the viewer regardless and show pps files. Use SetParent on the Viewer to nest it in a vb form.
If I setParent the viewer, will it display all the slides at once is the big question.
Can you show me how to setParent the powerpointviewer.exe and I will give it a go.
You can use command line switches to modify the way that PowerPoint 2003 Viewer runs. The command line switches for PowerPoint 2003 Viewer are as follows:
• /L - Use this switch to read a play list of PowerPoint presentations from a text file. For example, type the command Path\pptview.exe /L "Your_Play_List.txt" to view the PowerPoint presentations that are listed in the Your_Play_List.txt file.
• /S - Use this switch to start PowerPoint 2003 Viewer and not display the splash screen.
• /P - Use this switch to send the presentation to a printer, and print the file. For example, type the command Path\pptview.exe /P "Presentation.ppt" to print the Presentation.ppt file.
• /D - Use this switch to prompt the Open dialog box to appear when the slide show ends.
• /N# - Use this switch to open the presentation at a specified slide number. For example, type the command Path/pptview.exe /n5 "presentation.ppt" to open the presentation at slide 5.
Re: [2008] Display powerpoint slides on form and run slides from form
You may also be export the ppt to a stand alone slide show by selecting the export to CD option and then distributing the supporting files
That one's interesting to know - didn't know that.
Code:
If I setParent the viewer, will it display all the slides at once is the big question. Can you show me how to setParent the powerpointviewer.exe and I will give it a go.
SetParent is an API call which takes a given window handle and assigns it to a given parent window handle. Performing a search upon a search engine for vb and setparent yielded lots of samples. The suggestion above was for having your slideshow run in a pps file, then display this inside your form. You could perform the same with a ppt file, but you'd have the powerpoint application within your form and rather than that, the users should really use powerpoint directly in that scenario.
I am trying to display a scrolling control with all powerpoint slides within my app.
Related to that, the OP is trying to have a slideshow preview of all the slides upon his form - like on the left of a ppt file when you open it, it displays all of the slides to show.
I don't see an option to display all slides. But one can choose which slide number the viewer displays.
The OP did originally post a link to this one.
in my case I have PowerPoint9 & Office2000. I'm sure your code will work for end users who have >Office2000.
You have to tell us these bits of information as it can make all the difference to both our advice and code suggestions!
This code is updated to use late binding using the COM PowerPoint library and export the screenshots to JPeg files as well as rendering them on a form in pictureboxes. However again test it thoroughly - some of the method calls may not be in previous versions of PowerPoint and may require tweaking and also, I'm still with Rob on this one, though this sample looks ok here and uses the PowerPoint libraries to automate PowerPoint on a machine without it installed, I honestly can't see the slide showing on screen without any form of viewer or application installed. I might be wrong and have a play with it by all means (attached), but I can't really see this happening myself.
I'd point out and urge you to look at another thread - Klienma's got a great sample of the FindExecutable API call here: http://www.vbforums.com/showthread.php?t=323257 in his BrowserExec class which you could tweak to check whether the user can open a PowerPoint file or not - if not you could then start the installer of the viewer and either leave them with that, or embed a version within your form using the above SetParent API call advice.
Last edited by alex_read; Jul 16th, 2008 at 01:15 AM.
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
Thanks very much for your help on this Alex! In essence the code does what is required on systems with >Office 2000.
If we were to break up this app:
import slide images
display slide images
Your methodology of importing the slide images hinges on Powerpoint doing the work.
My suggestion is : for step 1 we should turn to a non-POwerpoint solution, something likeShell's IEExtract image but I don't know enough to get it to work.
Step 2 is fairly simple. Display all extracted images on form as you have done. Double-clicking image automates powerpoint viewer
Originally Posted by alex_read
though this sample looks ok here and uses the PowerPoint libraries to automate PowerPoint on a machine without it installed, I honestly can't see the slide showing on screen without any form of viewer or application installed.
My objective is for this to work on end user systems without Powerpoint by supplying the PP Viewer
Re: [2008] Display powerpoint slides on form and run slides from form
The above attachment has been re-uploaded with support for the dynamic controls being added to a scrollable panel control. This still uses powerpoint or the viewer unfortunately as I'm not sure theres another non-expensive way to accomplish your task without it (I kept an eye on your other thread noted above too).
The alterations required were as below. You will need to perform the 1st 2 in order for this sample to work on your computer/environment...
To place a panel control on the form
To set the Autoscroll property of the panel control to be true
To alter the code from reading FormName.Controls.Add to Panel1.Controls.Add in order to bind each picturebox control to a parent of the panel rather than the form
The left property of each picturebox control was easier to set and I altered this to a smaller number
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
Thanks very much Alex.
1. Instead of powerpoint instance opening fullscreen, Is there any way to host the powerpoint (small-sized) instance on maybe a form2 and capture slides from there ?
2. Also is there a way to display a red border around the picturebox that was clicked ?
3. Dunno if you noticed but for some reason the taskbar appears in the first couple (actually 3) of ppt snapshots.
4. This code works for =>Powerpoint 2003. Is there any way we can make this compatible with all versions of PP ie:- PP97 to PP2007 ?
Last edited by Xancholy; Jul 16th, 2008 at 08:45 AM.
Re: [2008] Display powerpoint slides on form and run slides from form
Originally Posted by Xancholy
1. Instead of powerpoint instance opening fullscreen, Is there any way to host the powerpoint (small-sized) instance on maybe a form2 and capture slides from there ?
3. Dunno if you noticed but for some reason the taskbar appears in the first couple (actually 3) of ppt snapshots.
This has baffled me - no it doesn't happen on my computers at all, I'm using version 2003 pro - do you see this behaviour on the viewer or 2007 versions?? The code calls on powerpoint to run in full screen presentation mode which should take up the entire screen - taskbar and all. Does this work if no other programs or hungry processes are running?
There is probably a way to grab the handle of the powerpoint window and make a screenshot of this, but as it won't be running in slideshow view, you'd be grabbing the left slide preview panel, all the menu and toolbars and status bars, the notes panel etc. of powerpoint and not just the slide content.
You could try a loop to iterate through the slides collection and use the slide.export method instead. This was mentioned on one of your current threads or perhaps a link was given upon one of these threads to a page which noted the slide.export method. I'm not aware of this method and haven't written any samples with it, but it looks as though you can export pictures of the slides using that which may help you here.
Originally Posted by Xancholy
2. Also is there a way to display a red border around the picturebox that was clicked ?
4. This code works for =>Powerpoint 2003. Is there any way we can make this compatible with all versions of PP ie:- PP97 to PP2007 ?
The code provided uses late binding so I'll be suprised if it doesn't work with 2007 also, I'm only using standard calls, I imagine it'd probably work for versions prior to 2003 also. Are you asking a question "will it be compatible", or have you tested this with 2007 and got some different behaviour? If so, what messages or behaviour can you see happening when run against a 2007 version?
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
Hi Xancholy!
I finally managed to look at the PowerPoint slide image export method and coded up a sample for you. This bypasses the screenshot taking and therefore you won't get the taskbar display. I've noticed it also runs much quicker also. Again this does depend on Powerpoint or the viewer being installed first off - as previous dicussion mentions but this should be of help if you're still using the above code. Final note is that I'm posting the code direct as I'm running out of the amount of attachments I can upload here!
With regard to Office 2003, I realise I left in a comment on the late binding which I should have removed. I altered this code to be late binding so this should work with 2003 and 2007 versions. The comment in question has now been removed.
Code:
Option Strict off
Imports System.Runtime.InteropServices.Marshal
Imports System.Diagnostics
Public Class Form1
#Region "ClassEnumerations"
Private Enum localMSOTriState
msoTrue = -1
msoFalse = 0
End Enum
Private Enum localPpAlertLevel
ppAlertsNone = 1
ppAlertsAll = 2
End Enum
Private Enum localPpSlideShowAdvanceMode
ppSlideShowManualAdvance = 1
ppSlideShowUseSlideTimings = 2
ppSlideShowRehearseNewTimings = 3
End Enum
#End Region
Private Const _dynamicPictureBoxNamePrefix As String = "SlidePictureBox"
Private Const _dodgyHardcodedPPTFileName As String = "C:\SampleFile.ppt"
Private Const _dodgyHardcodedSlideImageSaveName As String = "C:\_ExportedPPTSlideImage"
Private _slideIndex as Integer
Private _totalSlideCount as Integer
''' <summary>
''' Executes once the form is loaded into the application's form collection following instanciation but before rendering. Calls the OutputPowerPointFileSlides method.
''' </summary>
''' <param name="sender">Standard .Net delegate argument.</param>
''' <param name="e">Standard .Net delegate argument.</param>
''' <remarks>None.</remarks>
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
OutputPowerPointFileSlides(Me.Panel1, _DodgyHardcodedPPTFileName)
End Sub
''' <summary>
''' Executed when one of the dynamically created pictureboxes are clicked.
''' </summary>
''' <param name="sender">Standard .Net delegate argument. Relates to the control clicked upon at runtime.</param>
''' <param name="e">Standard .Net delegate argument. Relates to the click which occurred upon the sender object/argument at runtime.</param>
''' <remarks>This handles the click event of all the dynamically created picturebox controls. Within the method, the sender argument is evaluated at runtime to interprate which specific picturebox was clicked upon.</remarks>
Private Sub DynamicPictureBox_OnClick(ByVal sender As Object, ByVal e As System.EventArgs)
Dim _slideIndexNumber As Integer = CType(CType(sender, PictureBox).Name.Replace(_dynamicPictureBoxNamePrefix, String.Empty), Integer)
MessageBox.Show(String.Concat("Picture box number ", _slideIndexNumber.ToString, _
" was clicked!", Environment.NewLine, Environment.NewLine, _
"(Remember this is a zero-based sheet ID, PowerPoint recognises 1-based)"))
End Sub
''' <summary>
''' Uses PowerPoint to export slides of a given file and output these via a series of dynamically created picturebox controls upon a specified form.
''' </summary>
''' <param name="formPanelName">Name of the form panel control to add the picturebox controls to.</param>
''' <param name="PowerPointFileName">The path, name and extension of a PowerPoint file containing the slides to be exported and shown.</param>
''' <remarks>This method can be altered to accept a generic container control which would support forms or panels to contain the picturebox controls.</remarks>
Private Sub OutputPowerPointFileSlides(ByVal formPanelName As panel, ByVal PowerPointFileName As String)
Dim newPowerPointInstance As Object
Try
' Instanciate PowerPoint. This uses late binding contrary to the earlier made comment.
' Note there's no file validation check or error handling yet - I'll leave that to you! ;c)
' First, Open the given PowerPoint file.
newPowerPointInstance = CreateObject("PowerPoint.Application")
With newPowerPointInstance
.ShowStartupDialog = localMSOTriState.msoFalse
.DisplayAlerts = localPpAlertLevel.ppAlertsNone
.Visible = localMSOTriState.msoTrue
.Presentations.Open(PowerPointFileName)
End With
' Iterate through the slides collection of the currently open single presentation.
With newPowerPointInstance.Presentations(1).SlideShowSettings
for _slideIndex = 0 to newPowerPointInstance.Presentations(1).slides.count -1
' Export each powerpoint slide to a Jpeg image file upon the file system.
newPowerPointInstance.Presentations(1).slides(_slideIndex +1).export( _
string.Format("{0}{1}.jpg", _dodgyHardcodedSlideImageSaveName, _
_slideIndex.tostring), "JPG")
Next
End With
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
' Clean up code. Dispose of PowerPoint as it's no longer needed. Note there's 2 Try...Catch
' blocks within this single method. This is so PowerPoint can be disposed of as soon as possible
' with this code within the 1st Try block's Finally block.
If Not (newPowerPointInstance Is Nothing) Then
If (newPowerPointInstance.Presentations.Count > 0) Then
newPowerPointInstance.Presentations(1).close()
End If
newPowerPointInstance.DisplayAlerts = localPpAlertLevel.ppAlertsAll
newPowerPointInstance.Quit()
ReleaseComObject(newPowerPointInstance)
newPowerPointInstance = Nothing
For Each PowerPointProcess As Process In Process.GetProcessesByName("POWERPNT")
PowerPointProcess.Kill()
Next
End If
End Try
try
' With PowerPoint opened, the slides all exported to files then the PowerPoint instance terminated,
' we can start to tackle showing these slide files upon the screen. Firstly, instanciate a new
' collection object which will contain picturebox objects.
Dim newPictureBoxInstance As New List(Of PictureBox)
Dim pictureBoxTopPos As Integer = 10
_totalSlideCount = _slideIndex -1
' Then performing a loop to iterate through each of the earlier exported slide images from
' the given PowerPoint file. Notice there's no need for sizing or sleeping in this code.
For _slideIndex = 0 To _totalSlideCount
' With each slide and therefore loop iteration encountered, create a new picturebox
' control. These controls are created at runtime and are known as dynamic controls.
newPictureBoxInstance.Add(New PictureBox)
With newPictureBoxInstance(_slideIndex)
.Left = 5
.Height = 150
.Width = 150
.Top = CType((_slideIndex * newPictureBoxInstance(_slideIndex).Height) + 10, Integer)
' It's important to set the right size mode for the slide image to take up the picturebox height and
' width correctly. I also name each picturebox with an ending (zero-based) slide index number.
.SizeMode = PictureBoxSizeMode.Zoom
.Name = string.Concat(_dynamicPictureBoxNamePrefix, _slideIndex.ToString)
' Add an onclick event handler - this tells the .Net framework at runtime to call the above
' DynamicPictureBox_OnClick method when the picturebox is clicked onto.
AddHandler newPictureBoxInstance(_slideIndex).Click, AddressOf DynamicPictureBox_OnClick
' Call the below method to open the earlier exported PowerPoint slide file relating to the
' current loop index, and add this file as the current dynamic picturebox's image to render
' upon the screen.
dim exportedSlideBitmap as New Bitmap(string.Format( _
"{0}{1}.jpg", _dodgyHardcodedSlideImageSaveName, _slideIndex.ToString))
newPictureBoxInstance(_slideIndex).Image = exportedSlideBitmap
' With the picturebox control instanciated and it's relevant properties set, we can add this
' to the panel's controls collection and render this upon the screen.
formPanelName.controls.Add(newPictureBoxInstance(_slideIndex))
End With
Next _slideIndex
Catch ex As Exception
' Simply show a messagebox upon the screen if an exception occurrs for this sample project.
MessageBox.Show(ex.ToString)
end try
End Sub
End Class
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
A small change was made to correctly show the slide number clicked.
Code:
MessageBox.Show(String.Concat("Picture box number ", (_slideIndexNumber + 1).ToString, _
" was clicked!", Environment.NewLine, Environment.NewLine, _
"(Remember this is a zero-based sheet ID, PowerPoint recognises 1-based)"))
What I see at my end is
an instance of Powerpoint opens full screen and in the taskbar to the 1st slide
Then all slides thumbnails appear on Form1's Panel1
No taskbar on thumbnails!
Is it possible to Hide the instance of powerpoint altogether ?
I used to be able to do this in VBA but I'll try and remember the code.
I am in the process of testing it on a system without Office Installed - with just POwerpointViewer2007 installed.
Just outstanding - you're breaking ground. Thanks again.
Last edited by Xancholy; Jul 19th, 2008 at 09:35 AM.
Commenting out line 72 prevents the instance of PP from appearing onscreen & in the taskbar but code works perfectly.
Code:
'.Visible = localMSOTriState.msoFalse
Can this code work on systems without POwerpoint installed but with PowerpointViewer2007 installed ? No it can't. I tried it & it will generate exception "cannot create activex object' on line 68
Re: [2008] Display powerpoint slides on form and run slides from form
Sorry just managed to get back around to this thread.
I've tried searching the Internet for this but with no luck. I would try searching your hard drive for ppview or powerpointview - or perhaps right clicking the shortcut menu item pointing to the powerpoint viewer to look at what the name of the file is, then try using this within the CreateObject() call. This would definitely tell you whether you can code against the viewer or not and therefore whether that above sample works with the viewer rather than just the full version.
I wouldn't mind knowing the answer to this also if you could post the result when you've tried it. I guess if the code library accessing features aren't possible with the viewer, the last resorts as I see it are to have a pre-requitsite of your program's install to be for the user to have powerpoint installed, or to use an expensive component such as the above which utilises the powerpoint file format.
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
Not yet Mads. Alex's solution works great when PP exists on end user system.
I have not found any 3rd party solution that displays ppts when PP does not exist.
Automating PP Viewer2007 to display slides is not a problem. Creating a slidesorter preview on a form using PP Viewer 2007 is my objective. Let me know if you find anything.
Re: [2008] Display powerpoint slides on form and run slides from form
Have either of you found what the PowerPoint viewer executable name is (which might differ between versions) as described above? Have either of you tried using this filename (possibly with the path also, in the format "C:\FileName.exe") with the above code at this line (in replace of the "PowerPoint.Application" string):
Code:
CreateObject("PowerPoint.Application")
@Xancholy: You never actually said you'd tried this , I was waiting for a reply to see whether the CreateObject call works and therefore the viewer could be automated.
Please rate this post if it was useful for you!
Please try to search before creating a new post,
Please format code using [ code ][ /code ], and
Post sample code, error details & problem details
Re: [2008] Display powerpoint slides on form and run slides from form
Hi again
I found a solution to my problem... I don't know if this is something that might help you to Xancholy? But I managed to start the PP Viewer inside a form/panel and displaying a pps file...
vb Code:
Public Sub OpenPPViewerInForm()
Dim ppviewer As String = "C:\Program Files\Microsoft Office\PowerPoint Viewer\PPTVIEW.EXE"
I need to verify where it gets saved using Office 2000/2007. Anyone ?
Code:
Public Class Form1
Declare Function SetParent Lib "user32" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ppviewer As String = "C:\Program Files\Microsoft Office\Office12\PPTVIEW.EXE"
Dim MyPSI As New ProcessStartInfo(ppviewer)
MyPSI.Arguments = "c:\mypowerpoint.ppt /s"
Dim MyProcess As Process = Process.Start(MyPSI)
MyProcess.WaitForInputIdle()
SetParent(MyProcess.MainWindowHandle, Panel1.Handle)
End Sub
End Class
In the above code the powerpoint viewer window shows up in the taskbar. Is there any way to avoid that happening ?
Also is there a way to autosize the powerpoint slide so that it fits within Panel1 ?
Last edited by Xancholy; Aug 1st, 2008 at 03:00 PM.