-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPresentation.vb
42 lines (33 loc) · 1.49 KB
/
Presentation.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Imports System
Imports System.IO
Imports System.Drawing
Namespace PowerPointExport
Public Class Presentation
Private _powerPoint As Microsoft.Office.Interop.PowerPoint.Application
Private _presentation As Microsoft.Office.Interop.PowerPoint.Presentation
Protected Overrides Sub Finalize()
_powerPoint = Nothing
_presentation = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
End Sub
Public Sub New(ByVal paperSize As Size)
_powerPoint = New Microsoft.Office.Interop.PowerPoint.Application()
_presentation = _powerPoint.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse)
_presentation.PageSetup.SlideHeight = paperSize.Height
_presentation.PageSetup.SlideWidth = paperSize.Width
End Sub
Private _slideNo As Integer = 0
Public Sub AddPage(ByVal fileName As String)
_slideNo += 1
Dim slide = _presentation.Slides.Add(_slideNo, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutBlank)
slide.Shapes.AddPicture(fileName, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue, 0, 0)
End Sub
Public Sub SaveAs(ByVal filename As String)
If File.Exists(filename) Then File.Delete(filename)
_presentation.SaveAs(filename)
_presentation.Close()
_powerPoint.Quit()
End Sub
End Class
End Namespace