Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 447787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:36:18+00:00 2026-05-12T21:36:18+00:00

As far as I know, the code below gets a shape from the active

  • 0

As far as I know, the code below gets a shape from the active window, nudges it a bit, copies the slide and pastes it right after the current one, then turns the pasted slide into an active window, and nudges it again:

Sub Test()

' Get the active presentation

Dim oPresentation As Presentation
Set oPresentation = ActivePresentation

' Get the first slide in the presentation

Dim oSlide As Slide
Set oSlide = oPresentation.Slides(1)

' Get the first shape on the slide

Dim oShape As Shape
Set oShape = oSlide.Shapes(1)

' Nudge the shape to the right

oShape.Left = oShape.Left + 1

' Copy the whole slide

oSlide.Copy

' Paste the slide as a new slide at position 2

Dim oNewSlides As SlideRange
Set oNewSlides = oPresentation.Slides.Paste(2)

' Get a reference to the slide we pasted

Dim oNewSlide As Slide
Set oNewSlide = oNewSlides(1)

' Get the first shape on the NEW slide

Dim oNewShape As Shape
Set oNewShape = oNewSlide.Shapes(1)

' Nudge the shape to the right

oNewShape.Left = oNewShape.Left + 1

End Sub

As far as I can understand, in order to implement this code, I should have an active window opened and it should have at least one shape in it. Before I run this code I have only one slide; after the code has been run, I have two slides: the older one is number 1, and the newer one is number 2.

If I run this code one more time, I will get three slides as a result: the oldest one being still number 1, but the oldest one being number 2, not number 3.

My question is how can I make it produce slides, so that the newer slides are always the ones with a greater ordinal number, i.e. every newly created slide should be the last one in the slide preview sidebar (the lowest one)?

And also, how can I make it into a loop? So that I don’t need to re-run this code again and again, but simply make a loop with a given number of loop’s iterations.

I guess, if it should be a loop, then slides index should be turned into a variable, but I don’t know how to do it in PowerPoint VBA.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T21:36:18+00:00Added an answer on May 12, 2026 at 9:36 pm

    I’m not sure your code makes any sense. It essentially:

    1. Gets the 1st slide
    2. Gets the 1st shape on the slide
    3. Moves it 1 unit to the right
    4. Copies the 1st slide
    5. Pastes it in as the 2nd slide
    6. Gets the 1st shape on the new 2nd
      slide
    7. Moves it 1 unit to the right

    Why is it moving it twice, once on the original and once on the copy?

    Regardless to answer your specific questions:

    To paste it as the last slide, replace

    Set oNewSlides = oPresentation.Slides.Paste(2)
    

    With

    Set oNewSlides = oPresentation.Slides.Paste() #no index pastes as last
    

    To loop use something like this:

    Dim oPresentation As Presentation
    Set oPresentation = ActivePresentation
    
    Dim oSlide As Slide
    Dim oSlides As SlideRange
    Dim oShape As Shape
    Dim slideNumber As Integer
    
    For slideNumber = 1 To 10
    
        Set oSlide = oPresentation.Slides(oPresentation.Slides.Count)
        oSlide.Copy
        Set oNewSlides = oPresentation.Slides.Paste()
        Set oSlide = oNewSlides(1)
        Set oShape = oSlide.Shapes(1)
        oShape.Left = oShape.Left + 5
    
    Next slideNumber
    

    This takes the last slide, copies it, pastes the copy as the new last one, nudges the first shape to the right, takes new last slide, copies it, pastes the copy as the last one, nudges the first shape to the right, etc…. It’ll do this 10 times.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following function like this: Image('/path/to/original.image', '1/1', '150*', './thumb.jpg');… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer Check you database schema to see if the field (referenced… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I figured out the problem - there was a session… May 13, 2026 at 2:13 am

Related Questions

Imagine you have a large array of floating point numbers, of all kinds of
I was wondering if there is any sample code out there for objective-C for
In OpenGL in Delphi, I am attempting to calculate how much of a scene
According to the documentation of the == operator in MSDN , For predefined value

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.