<DllImport("user32.dll", EntryPoint := "FindWindow", SetLastError := True)> _
Private Shared Function FindWindow(ZeroOnly As IntPtr, lpWindowName As String) As IntPtr
End Function
<DllImport("user32.dll", SetLastError := True)> _
Private Shared Function SetParent(hWndChild As IntPtr, hWndNewParent As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", SetLastError := True, CharSet := CharSet.Auto)> _
Public Shared Function SetWindowText(hwnd As IntPtr, lpString As [String]) As Boolean
End Function
Private FileName As String = ""
Private application As PowerPoint.Application
Private presentation As PowerPoint.Presentation
Private flag As Boolean = False
Public Sub New()
InitializeComponent()
End Sub
Public Sub open()
sair()
openFileDialog1.Filter = "Powerpoint file (*.ppt)|*.ppt|All files (*.*)|*.*"
If openFileDialog1.ShowDialog() = DialogResult.OK Then
FileName = openFileDialog1.FileName
Dim screenClasshWnd As IntPtr = DirectCast(0, IntPtr)
Dim x As IntPtr = DirectCast(0, IntPtr)
flag = True
application = New PowerPoint.Application()
presentation = application.Presentations.Open2007(FileName, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue)
Dim sst1 As PowerPoint.SlideShowSettings = presentation.SlideShowSettings
sst1.ShowType = DirectCast(1, PowerPoint.PpSlideShowType)
Dim sw As PowerPoint.SlideShowWindow = sst1.Run()
sw.Height = (panel1.Height) - 64
sw.Width = (panel1.Width) - 130
Dim formhWnd As IntPtr = FindWindow(x, "Form1")
Dim pptptr As IntPtr = DirectCast(sw.HWND, IntPtr)
screenClasshWnd = FindWindow(x, "screenClass")
SetParent(pptptr, panel1.Handle)
Me.Focus()
Me.application.SlideShowEnd += New Microsoft.Office.Interop.PowerPoint.EApplication_SlideShowEndEventHandler(SlideShowEnds)
End If
End Sub
ดูเรื่อง Permission ด้วยครับ
ASP.NET Config PowerPoint (PowerPoint.Application)