Home > front end >  Powerpoint vba lock all shapes
Powerpoint vba lock all shapes

Time:06-13

does anyone knows how to lock all shapes from all slides in vba and also unlock in another macro

I've the beggining but I can't find how to apply the lock function

sub test
Dim oSlide As Slide
On Error Resume Next
For Each oSlide In ActivePresentation.Slides
oSlide.Shapes.SelectAll

xxx.locked

next
end sub

CodePudding user response:

Air code, but it should work, assuming you have a version of PPT that supports .Locked:

sub test
Dim oSlide As Slide
Dim oShape as Shape
On Error Resume Next
For Each oSlide In ActivePresentation.Slides
For Each oShape in oSlide.Shapes
   oShape.Locked = True
Next
Next
end sub

CodePudding user response:

the correct macro need to activate the slide before processing I'm looking for the next step "oSlide.Shapes.SelectAll" with lock to accelerate, if anyone...

 Sub Lock()  
    Dim oSlide As Slide  
    dim oShape As Shape  
    Dim slideIndex As Long
    
Set oSlide = Application.ActiveWindow.View.Slide 
oslideIndex = oSlide.slideIndex
    
On Error Resume Next 
For Each oSlide In ActivePresentation.Slides 

ActivePresentation.Slides(oSlide.slideIndex).Select
            For Each oShape In oSlide.Shapes
            oShape.Locked = True
            Next  
    Next  
    ActivePresentation.Slides(oslideIndex).Select  
    End Sub

CodePudding user response:

Here we go

Sub Lock()
Dim oSlide As Slide
Dim oShape As Shape
Dim slideIndex As Long
Set oSlide = Application.ActiveWindow.View.Slide
oSlideIndex = oSlide.slideIndex

On Error Resume Next
For Each oSlide In ActivePresentation.Slides
ActivePresentation.Slides(oSlide.slideIndex).Select
ActivePresentation.Slides(oSlide.slideIndex).Shapes.Range.Locked = msoTrue
Next
ActivePresentation.Slides(oSlideIndex).Select
End Sub
  • Related