PowerPoint shape size and delete

Hi.

I have some elements in a PowerPoint presentation that I need to change “manually” (in the Notes Master page, that is a mess in some files I received).

I created the script below, and it works, but not very well (I need to run it twice in the 160 slides). The logic is:

  1. The text frame called “Notes Placeholder 2” needs to have an specific size and position.
  2. Same for the image “Slide Image Placeholder 1”.
  3. There is a “Footer” element that need to be deleted.
  4. Same with a “Slide Number” element.

Any suggestions to improve it will help.

Thank you!
Luiz

tell application "Microsoft PowerPoint"
	activate
	
	repeat 160 times
		
		
		tell application "System Events"
			tell process "Microsoft PowerPoint"
				keystroke "a" using command down
				delay 0.5
			end tell
		end tell
		
		
		tell font of text range of selection of active window
			set font size to 11
			-- set font color to ({0, 0, 0} as RGB color)
			set font name to "Calibri"
		end tell
		
		
		--tell front document
		set allShapes to shape range of selection of active window
		set shapeCount to (count shapes of allShapes)
		
		set shapeList to {}
		-- set slideNumber to 1
		
		
		
		repeat with i from 1 to shapeCount
			
			try
				tell shape i of allShapes
					
					set nameE to name
					
					
					if nameE is "Notes Placeholder 2" or nameE is "Main Text" then
						
						set properties to {top:{390}, left position:{50}, width:{450}, height:{360}}
						set name to "Main Text"
						select
						delay 0.5
						
						
						
						
						tell application "System Events"
							tell process "Microsoft PowerPoint"
								keystroke "a" using command down
								delay 0.5
							end tell
						end tell
						
					end if
					
					if nameE is "Slide Image Placeholder 1" then
						
						set properties to {top:{90}, left position:{50}, width:{450}, height:{254}}
						set name to "Main Slide"
						
					end if
					
					try
						if nameE starts with "Footer" then
							select
							tell application "System Events"
								tell process "Microsoft PowerPoint"
									keystroke "x" using {command down}
									delay 1
								end tell
							end tell
							
							tell application "System Events"
								tell process "Microsoft PowerPoint"
									keystroke "a" using command down
									delay 0.5
								end tell
							end tell
							
						end if
						
					end try
					
					try
						
						if nameE starts with "Slide Number" then
							select
							tell application "System Events"
								tell process "Microsoft PowerPoint"
									keystroke "x" using {command down}
									delay 0.5
								end tell
							end tell
							
							
							
							
							tell application "System Events"
								tell process "Microsoft PowerPoint"
									keystroke "a" using command down
									delay 0.5
								end tell
							end tell
							
						end if
					end try
				end tell
			end try
			
		end repeat
		
		
		
		
		set theView to view of document window 1
		my goToNextSlide(theView)
		
		
		
		
	end repeat
	
end tell



on goToNextSlide(theView)
	tell application "Microsoft PowerPoint"
		activate
		set curSlide to slide index of slide range of selection of document window 1
		go to slide theView number (curSlide + 1)
	end tell
end goToNextSlide