VBA/Excel/Access/Word/PowerPoint/Slide Edit

Материал из VB Эксперт
Версия от 15:46, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Accessing a Slide by Name

   <source lang="vb">

Sub Name()

   ActivePresentation.Slides(1).Name = "Introduction"
   ActivePresentation.Slides("Introduction").Select

End Sub

</source>
   
  


assigns to the SlideRange object variable mySlideRange the slides named Intro and Outro in the active presentation:

   <source lang="vb">

Sub rangeArray()

   Set mySlideRange = ActivePresentation.Slides.Range(Array("Intro", "Outro"))

End Sub

</source>
   
  


Changing the Layout of an Existing Slide

   <source lang="vb">

Sub layout()

   ActivePresentation.Slides(1).Layout = ppLayoutClipArtAndVerticalText

End Sub

</source>
   
  


Copying and Pasting a Slide

   <source lang="vb">

Sub copy()

   ActivePresentation.Slides(1).Copy
   ActivePresentation.Slides.Paste Index:=5

End Sub

</source>
   
  


Deleting an Existing Slide

   <source lang="vb">

Sub del()

   ActivePresentation.Slides(1).Delete

End Sub

</source>
   
  


Duplicating a Slide

   <source lang="vb">

Sub Duplicate()

   ActivePresentation.Slides(4).Duplicate

End Sub

</source>
   
  


Finding a Slide by Its ID Number

   <source lang="vb">

Sub addFromFile()

   Dim TargetSlide As Long
   TargetSlide = ActivePresentation.Slides.Add(Index:=5,    Layout:=ppLayoutFourObjects).SlideID
   Presentations("C.ppt").Slides.InsertFromFile _
       FileName:="C:\A.ppt", Index:=3
   ActivePresentation.Slides.FindBySlideID(TargetSlide).ApplyTemplate _
       FileName:="C:\B.pot"

End Sub

</source>
   
  


Inserting Slides from an Existing Presentation

   <source lang="vb">

Sub insert()

   Presentations("Corporate.ppt").Slides.InsertFromFile _
       FileName:="C:\Your.ppt", Index:=5, _
       SlideStart:=2, SlideEnd:=8

End Sub

</source>
   
  


Moving a Slide

   <source lang="vb">

Sub move()

   ActivePresentation.Slides(3).MoveTo ToPos:=1

End Sub

</source>
   
  


Working with a Range of Slides

   <source lang="vb">

Sub range()

   Dim mySlideRange As SlideRange
   Set mySlideRange = Presentations("HR.ppt").Slides.Range(Array(1, 2, 3, 4, 5))

End Sub

</source>