How to automate with vb6 - can automate two lines but no more :-(

P

Phoenix1_uk

Have code from varies sites inc microsoft hwoever tried to add a third text
box and then it fails - would be useful as have certain automaticly
genereated results every week and not fancy copy/paste and/writing if I not
need to. Also want to auto genereate the images as well. Any ideas?

Code:
Private Sub Command2_Click()
' Start PowerPoint.
Dim ppApp As PowerPoint.Application
Set ppApp = CreateObject("Powerpoint.Application")

' Make it visible.
ppApp.Visible = True

' Add a new presentation.
Dim ppPres As PowerPoint.Presentation
Set ppPres = ppApp.Presentations.Add(msoTrue)

' Add a new slide.
Dim ppSlide1 As PowerPoint.Slide
Set ppSlide1 = ppPres.Slides.Add(1, ppLayoutText)

' Add some text.
ppSlide1.Shapes(1).TextFrame.TextRange.Text = "My first slide"
ppSlide1.Shapes(2).TextFrame.TextRange.Text = "Automating Powerpoint is
easy" & vbCr & "Using Visual Basic is fun!"

' Setup slide show properties.
With ppPres.Slides.Range.SlideShowTransition
.EntryEffect = ppEffectRandom
.AdvanceOnTime = msoTrue
.AdvanceTime = 5 ' 5 seconds per slide
End With

' Prepare and run the slide show.
With ppPres.SlideShowSettings
.ShowType = ppShowTypeKiosk
.LoopUntilStopped = msoTrue
.RangeType = ppShowAll
.AdvanceMode = ppSlideShowUseSlideTimings
.Run
End With

' Sleep so user can watch the show.
Sleep (15000)

' Clean up.
ppApp.Quit
End Sub
 
D

David M. Marcovitz

The problem is that you have added a slide of type ppLayoutText. That
slide type has two text placeholders already existing, and what you are
doing is adding text to the existing text placeholders. You have two
choices:

(1) Use a different layout that includes more than two text placeholders
(such as ppLayoutTwoColumnText,which has three text areas).

(2) Add your own text boxes with something like
ppSlide1.Shapes.AddTextbox. You can add as many text boxes to your slide
as you want and put as much text in them as you want.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top