Hi,
I've got a VBA script set up which copies a range from Excel, and pastes it in to PowerPoint.
I then count which shape number on the slide it is, so that I can resize it and place it on the slide where I want it.
I get a problem when counting the shapes on the slide.
After I have pasted in to PowerPoint, I loop through each shape on the slide.
As you'll see, I've got a MsgBox on each count. If this is commented out, my final ShapeNum = 3. However my pasted shape is shape 4 in this example.
If I uncomment the MsgBox, it counts 4 times and gives ShapeNum the correct value.
It's almost as if it's going too fast. However, I tried putting in a delay, and that didn't work. It only gets the correct value when I use the MsgBox line.
I'm sure this isn't the way to do it, so is anyone able to advise on how I can do this and get the correct result without a msgbox?
Many thanks
I've got a VBA script set up which copies a range from Excel, and pastes it in to PowerPoint.
I then count which shape number on the slide it is, so that I can resize it and place it on the slide where I want it.
I get a problem when counting the shapes on the slide.
After I have pasted in to PowerPoint, I loop through each shape on the slide.
VBA Code:
Dim shp As PowerPoint.Shape
Dim ShapeNum As Long
For Each shp In pSlide.Shapes
ShapeNum = ShapeNum + 1
'MsgBox "Shape Counted"
Next
As you'll see, I've got a MsgBox on each count. If this is commented out, my final ShapeNum = 3. However my pasted shape is shape 4 in this example.
If I uncomment the MsgBox, it counts 4 times and gives ShapeNum the correct value.
It's almost as if it's going too fast. However, I tried putting in a delay, and that didn't work. It only gets the correct value when I use the MsgBox line.
I'm sure this isn't the way to do it, so is anyone able to advise on how I can do this and get the correct result without a msgbox?
Many thanks