PowerPoint - accessing Presenters Notes

Hi.

I have some presentations here and I need to copy the text of the Presenters Notes from each slide (to another presentation), but I can’t find a way to access the Presenter Notes.

What I did was:

  1. Open both presentations.
  2. Put them side by side (so I can see what is happening).
  3. Put them in Notes Page View (couldn’t do it via AppleScript)
  4. Go to slide 1, keystroke TAB, TAB, SPACE, so I can enter the Notes box. COMMAND A, COMMAND C.
    5 Go to the other file, TAB, TAB, SPACE, COMMAND A, COMMAND V.
  5. Change slides in both.

It works, but based in keystrokes… Any idea? My full code is below.

Thank you,
Luiz

tell application "Microsoft PowerPoint"
	activate
	
	-- Get the list of open PowerPoint windows
	tell application "System Events"
		tell process "Microsoft PowerPoint"
			set windowList to windows
		end tell
	end tell
	
	-- Ensure exactly two PowerPoint files are open
	if (count of windowList) is not equal to 2 then return
	
	-- Assign Window 1 and Window 2
	set window1 to item 1 of windowList
	set window2 to item 2 of windowList
	
	
	-- Simulate the shortcut to switch to Notes Page View (CMD + 3)
	my setNotesPageView(window1)
	my setNotesPageView(window2)
	
	-- Loop through both presentations to ensure they are active
	my switchToWindow(window1)
	delay 0.5
	
	-- Define window size and position
	set windowWidth to 1600
	set windowHeight to 980
	set newX to 0
	set newY to 400
	
	-- Resize and move both windows
	tell application "System Events"
		tell process "Microsoft PowerPoint"
			set position of window1 to {newX, newY}
			set size of window1 to {windowWidth, windowHeight}
			set position of window2 to {newX + windowWidth, newY}
			set size of window2 to {windowWidth, windowHeight}
		end tell
	end tell
	
	
	-- Get total slides
	set totalSlides to count of slides of active presentation
	
	-- Function to switch window focus
	
	-- Loop through all slides
	repeat with slideIndex from 1 to totalSlides
		-- Switch to Window 1, copy text
		my switchToWindow(window1)
		my copyText()
		
		-- Switch to Window 2, paste text
		my switchToWindow(window2)
		my pasteText()
		
		-- Move to next slide in both windows
		my nextSlide()
		my switchToWindow(window1)
		my nextSlide()
	end repeat
end tell


on switchToWindow(targetWindow)
	tell application "System Events"
		tell process "Microsoft PowerPoint"
			perform action "AXRaise" of targetWindow
		end tell
	end tell
	delay 1
end switchToWindow

-- Function to copy text from active textbox
on copyText()
	tell application "System Events"
		key code 48 -- TAB
		delay 0.2
		key code 48 -- TAB
		delay 0.2
		key code 49 -- SPACE
		keystroke "a" using command down
		delay 0.3
		keystroke "c" using command down
		delay 0.5
	end tell
end copyText

-- Function to paste text into active textbox
on pasteText()
	tell application "System Events"
		key code 48 -- TAB
		delay 0.2
		key code 48 -- TAB
		delay 0.2
		key code 49 -- SPACE
		keystroke "a" using command down
		delay 0.3
		keystroke "v" using command down
		delay 0.5
	end tell
end pasteText

-- Function to move to the next slide
on nextSlide()
	tell application "System Events"
		key code 53 -- ESC
		delay 0.2
		key code 53 -- ESC
		delay 0.2
		key code 125 -- Down Arrow
		delay 0.5
	end tell
end nextSlide

on setNotesPageView(targetWindow)
	my switchToWindow(targetWindow)
	delay 0.5
	tell application "System Events"
		keystroke "3" using command down
	end tell
	delay 0.5
end setNotesPageView

Belatedly, try something like this. Powerpoint offers the ability to manipulate the notes directly so you can avoid using various UI methods.

It checks that each presentation has the same number of slides and if they do, sets the second presentation note for each slide to match that of the first presentation slide. You could get it to append the note with a minor change.

set srcNotes to {}
set desNotes to {}
tell application "Microsoft PowerPoint"
	set p1 to presentation "pres.pptx"
	set d1 to presentation "dest.pptx"
	
	-- length of each presentation
	set l1 to count of slides of p1
	set l2 to count of slides of d1
	if l1 is equal to l2 then -- test that  presentations have an equal number of slides
		
		repeat with s from 1 to l1
			
			-- produce list of notes of presentation 1			
			set end of srcNotes to (content of text range of text frame of place holder 2 of notes page of slide s of p1)
			
			-- overwrite presentation 2 note with that of presentation 1 
			set content of text range of text frame of place holder 2 of notes page of slide s of d1 to last item of srcNotes
			
			-- produce list of notes of presentation 2
			set end of desNotes to content of text range of text frame of place holder 2 of notes page of slide s of d1
			
		end repeat
		
		set theyMatch to srcNotes is equal to desNotes
		if theyMatch then display dialog "Presentations' notes now match" giving up after 3
	else
		display dialog "Presentations do not match"
	end if
end tell

I got the syntax here, which is a good thing because it is very obscure.

Some additional information on scripting powerpoint is here on an old MacTech page

1 Like

Perfect! It is very hard to work with PPTs in AppleScript! Thanks a lot for your help!

1 Like