Format keynote slides with specific conditions

I am new to applescript’ing. Need your help to achieve my task.

I want to automate formatting my keynote.

My requirement is:
I have a Table with 4 columns and 3 rows.

Applescript should loop each of the row and

  1. if it see word “Bullet” it should get “Bullet”(bold)
  2. extra new lines should be deleted.
    Can anyone please help?

Bullets or numbers to text
Use bullets or numbers to present lots of text or a sequential process in a PowerPoint 2013 presentation.

On the VIEW tab, in the Presentation Views group, click Normal.
On the left-hand side of the PowerPoint window, click a slide thumbnail that you want to add bulleted or numbered text to.

On the slide, select the lines of text in a text placeholder or table that you want to add bullets or numbering to.

On the HOME tab, in the Paragraph group, click Bullets or Numbering.

Model: MacBook Pro
AppleScript: 2.11
Browser: Safari 537.36
Operating System: macOS 10.14

From my point of view, you aren’t clear.
Are you asking about the application “Keynote” or about the application “PowerPoint” ?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 8 mai 2020 11:19:48

I am asking about application “Keynote”

Thank you. I was afraid of that.

In the set of actions which may be executed via standard AppleScript upon Keynote, none is able to change the style of a chunk of text from standard to bold.
More, none is able to tell us if the contents of a cell is standard text or bold text.

tell application "Keynote"
	tell document 1 to tell current slide
		tell table 1 to tell cell 2 of column 1
			its value --> "Bullet" , plain text value
			its formatted value --> "Bullet" , plain text value
				its text item --> error number -1728 from text item of cell 2 of column 1 of table 1 of current slide of document 1
			end try
		end tell
	end tell
end tell
tell application "System Events" to tell process "Keynote"
	set frontmost to true
	tell window 1
		class of UI elements --> {radio group, UI element, button, button, static text, scroll area, scroll area, scroll area, button, button, button, menu button, toolbar, static text, static text}
		position of scroll areas --> {{1900, 350}, {838, 141}, {696, 141}}
		tell scroll area 2 -- the one containing the table
			class of UI elements --> {}
		end tell
	end tell
end tell

So I really don’t know how what you want would be achieved.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) vendredi 8 mai 2020 15:01:26

Thanks Yvan Koenig for your reply. I really appreciate your help.

As I am completely new to AppleScript, I didn’t get much of the logic you explained. But still I am trying.

Let me explain what actually I am trying to achieve.

Every day I get a keynote from my team which I share with my higher management. Keynote formatting is messy. I have to manually format it. Its taking lot of time. Hence I try to do it via AppleScript.

  1. Loop through all the slides(Tables in slides too). If Bullet text is there, just bold that text.

  2. In all the slides, if there is a blank line(within each column of a table) then delete it.

These are the only 2 things which I am trying to achieve via AppleScript.

Hope I am clear this time.

Thanks, MJ7

In my late message, I tried to explain that neither standard Applescript nor GUIScripting may achieve this task.
It seems that my explanations were not clear enough.
To be short, as far as I know, we have no way to change the content of a cell from standard to bold using AppleScript.

Here is a way to remove empty rows

tell application "Keynote" to tell document 1
	tell current slide
		if exists table 1 then
			tell table 1
				repeat with r from (count rows) to 1 by -1
					set isEmpty to true
					tell row r
						repeat with c from 1 to count columns
							if value of cell c is not missing value then
								set isEmpty to false
								exit repeat
							end if
						end repeat
					end tell
					if isEmpty then delete row r
				end repeat
			end tell
		end if
	end tell
end tell

You were clear.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 11 mai 2020 11:44:54