Untitled
unknown
plain_text
2 years ago
1.8 kB
8
Indexable
Certainly! Below is a simple VBA code that creates a PowerPoint presentation about the animal lion. This code will create a new presentation, add a title slide, and then add a slide with a lion image and some text.
```vba
Sub CreateLionPresentation()
Dim pptApp As Object
Dim pptPresentation As Object
Dim pptSlide As Object
Dim pptTextbox As Object
' Create a new PowerPoint application
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True ' Make PowerPoint application visible
' Create a new presentation
Set pptPresentation = pptApp.Presentations.Add
' Add a title slide
Set pptSlide = pptPresentation.Slides.Add(1, ppLayoutTitle)
pptSlide.Shapes(1).TextFrame.TextRange.Text = "Lion Presentation"
pptSlide.Shapes(2).TextFrame.TextRange.Text = "A majestic animal"
' Add a content slide with a lion image and text
Set pptSlide = pptPresentation.Slides.Add(2, ppLayoutText)
pptSlide.Shapes.AddPicture "path_to_lion_image.jpg", False, True, 100, 100, 400, 300 ' Replace "path_to_lion_image.jpg" with the actual image path
Set pptTextbox = pptSlide.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, Left:=100, Top:=400, Width:=400, Height:=50)
pptTextbox.TextFrame.TextRange.Text = "The lion is a powerful and majestic animal."
' Save the presentation
pptPresentation.SaveAs "LionPresentation.pptx"
' Clean up
pptPresentation.Close
pptApp.Quit
Set pptTextbox = Nothing
Set pptSlide = Nothing
Set pptPresentation = Nothing
Set pptApp = Nothing
End Sub
```
Make sure to replace `"path_to_lion_image.jpg"` with the actual file path of the lion image you want to use. You can also customize the title and text as needed. Run this VBA code in your PowerPoint application to create the presentation.Editor is loading...