- Joined
- Oct 29, 2015
- Messages
- 2
- Reaction score
- 0
Hi
I am quite new to VBA in general and I am currently working on a VBA code in PowerPoint which loops through different shapes on one slide (Slide 2) to compare if they are the same. If they aren’t, the text inside the shapes is copied into another slide (slide 1). The code for comparing shape 2 only is below. I want to loop this code for shapes which are named 2 to 6. I have been trying to do this for ages but I haven’t had any success. I tried replacing Shapes(2) with Shapes (i) but that didn’t work either. Can anyone help me please?
Sub step1()
If ActivePresentation.Slides(1).Shapes("1").TextFrame2.TextRange.Characters.Text <> ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text Then
If ActivePresentation.Slides(1).Shapes("2").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("2").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
Else
If ActivePresentation.Slides(1).Shapes("3").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("3").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
Else
If ActivePresentation.Slides(1).Shapes("4").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("4").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
Else
If ActivePresentation.Slides(1).Shapes("5").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("5").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
Else
If ActivePresentation.Slides(1).Shapes("6").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("6").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
End If
End If
End If
End If
End If
End If
End Sub
I am quite new to VBA in general and I am currently working on a VBA code in PowerPoint which loops through different shapes on one slide (Slide 2) to compare if they are the same. If they aren’t, the text inside the shapes is copied into another slide (slide 1). The code for comparing shape 2 only is below. I want to loop this code for shapes which are named 2 to 6. I have been trying to do this for ages but I haven’t had any success. I tried replacing Shapes(2) with Shapes (i) but that didn’t work either. Can anyone help me please?
Sub step1()
If ActivePresentation.Slides(1).Shapes("1").TextFrame2.TextRange.Characters.Text <> ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text Then
If ActivePresentation.Slides(1).Shapes("2").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("2").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
Else
If ActivePresentation.Slides(1).Shapes("3").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("3").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
Else
If ActivePresentation.Slides(1).Shapes("4").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("4").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
Else
If ActivePresentation.Slides(1).Shapes("5").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("5").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
Else
If ActivePresentation.Slides(1).Shapes("6").TextFrame2.TextRange.Characters.Text = "" Then
ActivePresentation.Slides(1).Shapes("6").TextFrame2.TextRange.Characters.Text = ActivePresentation.Slides(2).Shapes("2").TextFrame2.TextRange.Characters.Text
End If
End If
End If
End If
End If
End If
End Sub