Has anyone else come across this 256 character limit in PowerPoint with AppleScript? (PPT Version 2004, AppleScript 1.9.3, OSX 10.3.9)
The below code works fine provided that the text in the PowerPoint text box is 256 characters or less. Any more and PowerPoint crashes during script execution (while at the “set old_String to the content…” line).
tell application "Microsoft PowerPoint"
activate
set this_presentation to the active presentation
set this_slide to the slide of the view of document window 1
set shape_count to the count of shapes of this_slide
set shape_to_check to shape shape_count of this_slide
if has text frame of shape_to_check then
set shape_text_Obj to the text range of text frame of shape_to_check
set text_Length to the text length of shape_text_Obj
set old_String to the content of text range of text frame of shape_to_check
set content of shape_text_Obj to old_String & " Length=" & text_Length
end if
end tell
FYI for anyone else who comes across this problem, the workaround is to use the copy/paste commands to retrieve text longer than 256 characters. That can get pretty convoluted depending on what you need to do, but at least it won’t crash PowerPoint.
tell application "Microsoft PowerPoint"
activate
set this_presentation to the active presentation
set this_slide to the slide of the view of document window 1
set shape_count to the count of shapes of this_slide
set shape_to_check to shape shape_count of this_slide
if has text frame of shape_to_check then
set shape_text_Obj to the text range of text frame of shape_to_check
set text_Length to the text length of shape_text_Obj
--set old_String to the content of text range of text frame of shape_to_check -------Crashes with more than 256 characters
--set content of shape_text_Obj to old_String & " Length=" & text_Length
copy text range shape_text_Obj ------------Works with more than 256 characters
paste object view of document window 1
end if
end tell