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