cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
hogi
Level XII

Powerpoint: trigger paste clipboard

Does Jmp have a possibility to trigger "paste clipboard" in Powerpoint - after copying a graph to the clipboard.

1 ACCEPTED SOLUTION

Accepted Solutions
julian
Community Manager Community Manager

Re: Powerpoint: trigger paste clipboard

Hi @hogi,

My favorite way to do things like this (on my Mac) is to use RunProgram() to run some AppleScript. Here's my process there, which I hope will be helpful if you're adapting for Windows.

 

On the JMP side, we're going to use RunProgram() to execute a bash script we'll make:

Run Program( Executable( "~/Desktop/pastePowerpoint" ) );

To make the bash script, we open a plain text file and write the bash to AppleScript invocation, and then the AppleScript. Here's the full contents of that plain text file:

#!/bin/bash

osascript <<END
tell application "Microsoft PowerPoint"
  activate
  tell application "System Events"
    keystroke "v" using {command down}
  end tell
end tell
END

Once we save that (with no extension), we need to make it executable. In Terminal, we can run the following (still assuming this is on your desktop):

chmod 755 ~/Desktop/pastePowerpoint

 

And that's it! Hope this helps!

 

@julian  

View solution in original post

3 REPLIES 3
julian
Community Manager Community Manager

Re: Powerpoint: trigger paste clipboard

Hi @hogi,

My favorite way to do things like this (on my Mac) is to use RunProgram() to run some AppleScript. Here's my process there, which I hope will be helpful if you're adapting for Windows.

 

On the JMP side, we're going to use RunProgram() to execute a bash script we'll make:

Run Program( Executable( "~/Desktop/pastePowerpoint" ) );

To make the bash script, we open a plain text file and write the bash to AppleScript invocation, and then the AppleScript. Here's the full contents of that plain text file:

#!/bin/bash

osascript <<END
tell application "Microsoft PowerPoint"
  activate
  tell application "System Events"
    keystroke "v" using {command down}
  end tell
end tell
END

Once we save that (with no extension), we need to make it executable. In Terminal, we can run the following (still assuming this is on your desktop):

chmod 755 ~/Desktop/pastePowerpoint

 

And that's it! Hope this helps!

 

@julian  

hogi
Level XII

Re: Powerpoint: trigger paste clipboard

Thanks @julian.

Concening Windows, ChatGPT suggested to use a PowerShell Script:
(assuming that the JSL script and ps1 code are saved in the same folder)

Try(Current Report()<< Copy Picture();
If( Host is( "Windows" ),
PowerShellScriptName= Convert File Path( "", windows ) ||"PastePicture.ps1";
runOptions = "-File \!""|| PowerShellScriptName||"\!"";
MyResult = Run Program(
	Executable( "PowerShell.exe" ),
	Options( {runOptions} ),
	ReadFunction( Function( {this}, Write( this << read ) ) )
)
));

pastePicture.ps1:

$ppt = New-Object -ComObject PowerPoint.Application
$ActivePPT = $ppt.ActiveWindow
if ($ActivePPT -eq $null) {
  return "no active ppt"
} else {
$slide=$activeppt.Presentation.Slides($ppt.ActiveWindow.Selection.SlideRange.SlideNumber)
$shape = $slide.Shapes.Paste()
return 0
}

 

 

hogi
Level XII

Re: Powerpoint: trigger paste clipboard

I added the windows version (via PowerShell) to the GraphBuilder toolbar:
Graph Builder Toolbar 

 

hogi_0-1678381476411.png