I am using code to insert a picture, then a scroll bar - I then want to
be able to place code in the slide for the scroll bar change and scroll
events. The scroll bar value then controls the top position of the
added picture.
I sort of figured out crude way to do this but it am open to any
suggestions.
Here is what I have so far. This is all "hard coded" - ultimately I
want it to prompt for a file name and then place the picture and
scrollbar on the active slide and then place the code in the active
slide to control the scrollbar.
Sub InsertGraphicOnSlide()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppShape As PowerPoint.Shape
Dim ppCurrentSlide As PowerPoint.Slide
Set ppApp = CreateObject("PowerPoint.Application")
ppApp.Visible = True
'Set ppPres = ppApp.Presentations.Add(msoTrue)
'Set ppCurrentSlide = ppPres.Slides.Add(Index:=1, _
Layout:=ppLayoutBlank)
'Set ppCurrentSlide = ActiveWindow.Selection.SlideRange
With ActiveWindow.Selection.SlideRange.Shapes
Set opicture = .AddPicture("c:\Picture1.png", _
msoFalse, msoTrue, 0, 0, 1, 1)
opicture.ScaleHeight 1, msoTrue
opicture.ScaleWidth 1, msoTrue
opicture.Name = "Graphic_1"
End With
ActiveWindow.Selection.SlideRange.Shapes.AddOLEObject _
(Left:=618#, Top:=156#, Width:=12#, Height:=294#,
ClassName:="Forms.ScrollBar.1", Link:=msoFalse).Select
With ActivePresentation.VBProject.VBComponents(Slide1).CodeModule
.InsertLines 1, _
"Private Sub ScrollBar1_change()" & Chr(13) & _
"ScrollBar1.SmallChange = 1" & Chr(13) & _
"ScrollBar1.Max = 100" & Chr(13) & _
"ScrollBar1.Min = 0" & Chr(13) & _
"Ht = Shapes(""Graphic_1"").Height" & Chr(13) & _
"Increment = 77.04 + ((496.8 - (Ht + 77.04)) * ScrollBar1.Value /
ScrollBar1.Max)" & Chr(13) & _
"'increment = 48 + (-1.2762 * ScrollBar1.Value)" & Chr(13) & _
"ActivePresentation.SlideShowWindow.View.Slide.Shapes(""Graphic_1"").Top
= Increment" & Chr(13) & _
"End Sub"
End With
End Sub