I am writing excel VBA program to make a popwerpoint presentation and assign predefined text to each slide depending on number. I am using if condition to check the image number and assigning text to slide.
Below is the code I have written -
Expand|Select|Wrap|Line Numbers
- Private Const imgSlide1 = "Example1"
- Private Const imgSlide2 = "Example2"
- Private Const imgSlide3 = "Example3"
- Private Const imgSlide4 = "Example4"
- imgCnt=1
- picCnt=9
- While imgCnt <= picCnt
- ppApp.ActiveWindow.View.GotoSlide (slideNo)
- Set ppSlide = ppApp.ActivePresentation.Slides(slideNo)
- If imgCnt = 1 Then
- ppSlide.Shapes(2).TextFrame.TextRange.Text = imgSlide1
- ElseIf imgCnt = 2 Then
- ppSlide.Shapes(2).TextFrame.TextRange.Text = imgSlide2
- ElseIf imgCnt = 3 Then
- ppSlide.Shapes(2).TextFrame.TextRange.Text = imgSlide3
- ElseIf imgCnt = 4 Then
- ppSlide.Shapes(2).TextFrame.TextRange.Text = imgSlide4
- End If
- imgCnt = imgCnt + 1
Expand|Select|Wrap|Line Numbers
- imgCnt=1
- picCnt=9
- While imgCnt <= picCnt
- ppApp.ActiveWindow.View.GotoSlide (slideNo)
- Set ppSlide = ppApp.ActivePresentation.Slides(slideNo)
- 'Here for const 1,2,3,4 I want to user imgCnt variable value and will concate it to imSlide as shown below
- 'but it is not working
- ppSlide.Shapes(2).TextFrame.TextRange.Text = "imgSlide" & imgCnt
- imgCnt = imgCnt + 1
Could you please let me know how to fix it.