Slettet bruger
09. november 2005 - 17:37
#1
Jeg fandt selv ud af det...
Imports PowerPoint = Microsoft.Office.Interop.PowerPoint
Imports Office = Microsoft.Office.Core
Imports Graph = Microsoft.Office.Interop.Graph
og Funktionen:
Const sTemplate = "C:\Programmer\Microsoft Office\Templates\Presentation Designs\Blends.pot"
Const sPic = "C:\WINDOWS\Rhododendron.bmp"
Dim oApp As PowerPoint.Application
Dim oPres As PowerPoint.Presentation
Dim oSlide As PowerPoint.Slide
Dim bAssistantOn As Boolean
'Start Powerpoint and make its window visible but minimized.
oApp = New PowerPoint.Application
oApp.Visible = True
oApp.WindowState = PowerPoint.PpWindowState.ppWindowMinimized
'Create a new presentation based on the specified template.
oPres = oApp.Presentations.Open(sTemplate, , , True)
'Build Slide #1:
'Add text to the slide, change the font and insert/position a
'picture on the first slide.
Dim i As Integer
For i = 1 To 10
oSlide = oPres.Slides.Add(i, PowerPoint.PpSlideLayout.ppLayoutTitleOnly)
With oSlide.Shapes.Item(1).TextFrame.TextRange
.Text = "Side " & i.ToString
.Font.Name = "Comic Sans MS"
.Font.Size = 48
End With
oSlide.Shapes.AddPicture(sPic, False, True, 150, 150, 500, 350)
Next
oSlide = Nothing
'Modify the slide show transition settings for all 3 slides in
'the presentation.
Dim slideidx(10) As Integer
For i = 1 To 10
slideidx(i) = i
Next
With oPres.Slides.Range(slideidx).SlideShowTransition
.AdvanceOnTime = False
.EntryEffect = PowerPoint.PpEntryEffect.ppEffectBoxOut
End With
Dim oSettings As PowerPoint.SlideShowSettings
oSettings = oPres.SlideShowSettings
oSettings.StartingSlide = 1
oSettings.EndingSlide = 10
'Prevent Office Assistant from displaying alert messages.
bAssistantOn = oApp.Assistant.On
oApp.Assistant.On = False
'Close the presentation without saving changes and quit PowerPoint.
oPres.Export("C:\temp.ppt", "PPT", , )
oPres.Saved = True
oPres.Close()
oPres = Nothing
oApp.Quit()
oApp = Nothing
GC.Collect()
Relativt simpelt når man ved hvordan ;-)