BookmarkSubscribe
Choose Language Hide Translation Bar
Arthur_Wesley
New Contributor

Pasting Clipboard into external documents using JSL

I am trying to use JSL to automatically copy and paste a large number of images generated in JMP into Microsoft word. I've figured out how to copy them images using the "picture_box << Copy Picture;" functionality. However I am unsure how/if there is an easy way to paste the images into microsoft word once they are coppied

 

thanks!

0 Kudos
2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Pasting Clipboard into external documents using JSL

The methodology you need to use is to move the required graphs into a JMP journal, and then when done, use the Save MSWord(), to save the journal to a Word document.  Here is a little example:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
biv = Bivariate( Y( :height ), X( :weight ) );

jw = New Window( "My Journal", <<journal );

Report( biv ) << journal;

biv = oneway( Y( :height ), X( :sex ) );

Report( biv ) << journal;

jw << save MSWORD( "path\to\MSWordTest.doc" );
Jim
pmroz
Super User

Re: Pasting Clipboard into external documents using JSL

Here's a way to do it without using a journal.  The page break box() insures that each graph is on a separate page.

dt = open("$sample_data\Airline Delays.jmp");
graph1_expr = expr(
	dt << Graph Builder( Show Control Panel( 0 ),
		Variables( X( :Day of Month ), Y( :Month ), Color( :Arrival Delay ) ),
		Elements( Heatmap( X, Y, Legend( 5 ) ) ),
		SendToReport(
			Dispatch( {}, "Day of Month", ScaleBox,
				{Label Row( Show Major Ticks( 0 ) )} ),
			Dispatch( {}, "Month", ScaleBox,
				{Reversed Scale, Label Row( Show Major Ticks( 0 ) )} ),
			Dispatch( {}, "400", ScaleBox,
				{Legend Model( 5, Properties( 0,
						{gradient( {Scale Values( [-10 2.5 15 27.5 40] ),
							Label Format( "Fixed Dec", 15, 0 )}
						)},
						Item ID( "Arrival Delay", 1 ) ) )} ),
			Dispatch( {}, "graph title", TextEditBox, 
				{Set Text( "Arrival Delays by Day" )} )
		)
	);
);
graph2_expr = expr(
	dt << Graph Builder( Show Control Panel( 0 ),
		Variables( X( :Day of Week ), Overlay( :Airline ) ),
		Elements( Bar( X, Legend( 2 ) ) ),
		SendToReport( Dispatch( {}, "graph title", TextEditBox,
				{Set Text( "Flights by Airline and Day of Week" )}
			)
		)
	);
);
graph3_expr = expr(
	dt << Graph Builder( Show Control Panel( 0 ),
		Variables( X( :Distance ), Wrap( :Airline ) ),
		Elements( Histogram( X, Legend( 9 ) ) ),
		SendToReport(
			Dispatch( {}, "Distance", ScaleBox,
				{Min( -6.07535604831441 ), Max( 2900 ), Inc( 500 ), Minor Ticks( 0 ),
				Label Row( Label Orientation( "Angled" ) )} ),
			Dispatch( {}, "graph title", TextEditBox,
				{Set Text( "Flight Distance by Airline" )} )
		)
	);
);

//------------------------------------------------------------------------------
ma_win = new window("Multiple Charts", 
	panelbox("Actions",
		hlistbox(
			msword_button = buttonbox("Save to MS-Word",
				g_output << save msword("", Native);
			),
			close_button = buttonbox("Close this window",
				ma_win << close window;
			),
		),
	),
	g_output = vlist box(
		graph1_expr,
		page break box(),
		graph2_expr,
		page break box(),
		graph3_expr
	)
);

msword_button << set icon("WinFileSave");
close_button  << set icon("Stop"); 
4 REPLIES 4
txnelson
Super User

Re: Pasting Clipboard into external documents using JSL

You use

Save MSWord( path );
Jim
0 Kudos
Arthur_Wesley
New Contributor

Re: Pasting Clipboard into external documents using JSL


@txnelson wrote:
You use
Save MSWord( path );

I guess I wasn't clear in my OP, I am trying to save Multiple images generated in JMP to One Doccument ie.

 

for(i = 0, i <10, i++,
// Generate new images
// copy images in JMP
// paste image into Microsoft word
)

The Save MSWord() Function creates a new Microsoft word file and so is not compatable with this code.


0 Kudos
txnelson
Super User

Re: Pasting Clipboard into external documents using JSL

The methodology you need to use is to move the required graphs into a JMP journal, and then when done, use the Save MSWord(), to save the journal to a Word document.  Here is a little example:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
biv = Bivariate( Y( :height ), X( :weight ) );

jw = New Window( "My Journal", <<journal );

Report( biv ) << journal;

biv = oneway( Y( :height ), X( :sex ) );

Report( biv ) << journal;

jw << save MSWORD( "path\to\MSWordTest.doc" );
Jim
pmroz
Super User

Re: Pasting Clipboard into external documents using JSL

Here's a way to do it without using a journal.  The page break box() insures that each graph is on a separate page.

dt = open("$sample_data\Airline Delays.jmp");
graph1_expr = expr(
	dt << Graph Builder( Show Control Panel( 0 ),
		Variables( X( :Day of Month ), Y( :Month ), Color( :Arrival Delay ) ),
		Elements( Heatmap( X, Y, Legend( 5 ) ) ),
		SendToReport(
			Dispatch( {}, "Day of Month", ScaleBox,
				{Label Row( Show Major Ticks( 0 ) )} ),
			Dispatch( {}, "Month", ScaleBox,
				{Reversed Scale, Label Row( Show Major Ticks( 0 ) )} ),
			Dispatch( {}, "400", ScaleBox,
				{Legend Model( 5, Properties( 0,
						{gradient( {Scale Values( [-10 2.5 15 27.5 40] ),
							Label Format( "Fixed Dec", 15, 0 )}
						)},
						Item ID( "Arrival Delay", 1 ) ) )} ),
			Dispatch( {}, "graph title", TextEditBox, 
				{Set Text( "Arrival Delays by Day" )} )
		)
	);
);
graph2_expr = expr(
	dt << Graph Builder( Show Control Panel( 0 ),
		Variables( X( :Day of Week ), Overlay( :Airline ) ),
		Elements( Bar( X, Legend( 2 ) ) ),
		SendToReport( Dispatch( {}, "graph title", TextEditBox,
				{Set Text( "Flights by Airline and Day of Week" )}
			)
		)
	);
);
graph3_expr = expr(
	dt << Graph Builder( Show Control Panel( 0 ),
		Variables( X( :Distance ), Wrap( :Airline ) ),
		Elements( Histogram( X, Legend( 9 ) ) ),
		SendToReport(
			Dispatch( {}, "Distance", ScaleBox,
				{Min( -6.07535604831441 ), Max( 2900 ), Inc( 500 ), Minor Ticks( 0 ),
				Label Row( Label Orientation( "Angled" ) )} ),
			Dispatch( {}, "graph title", TextEditBox,
				{Set Text( "Flight Distance by Airline" )} )
		)
	);
);

//------------------------------------------------------------------------------
ma_win = new window("Multiple Charts", 
	panelbox("Actions",
		hlistbox(
			msword_button = buttonbox("Save to MS-Word",
				g_output << save msword("", Native);
			),
			close_button = buttonbox("Close this window",
				ma_win << close window;
			),
		),
	),
	g_output = vlist box(
		graph1_expr,
		page break box(),
		graph2_expr,
		page break box(),
		graph3_expr
	)
);

msword_button << set icon("WinFileSave");
close_button  << set icon("Stop");