cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
WebDesignesCrow
Super User

Script for add-in to allow user pick file in a directory

Hello JMP expert,

 

 I want to build an add-in that can ask user to put file of interest (i.e import .xlsx file into .jmp) then only the rest of script will run.

I have many files in the main folder.

How do i change below script to be able the user pick the directory in "C:\User\Data" folder at the first place?

I've tried to use pick file & pick directory within the () but not working. may be I messed-up something

Thanks.

This is JMP 17

 

//Open  Table
dt1= Open(
	"C:\User\Data\PlatingToneDatasheet.xlsx",
	Worksheets( {"Merge1"} ),
	Use for all sheets( 1 ),
	Concatenate Worksheets( 1 ),
	Create Concatenation Column( 0 ),
	Worksheet Settings(
		1,
		Has Column Headers( 1 ),
		Number of Rows in Headers( 1 ),
		Headers Start on Row( 1 ),
		Data Starts on Row( 2 ),
		Data Starts on Column( 1 ),
		Data Ends on Row( 0 ),
		Data Ends on Column( 0 ),
		Replicated Spanned Rows( 1 ),
		Replicated Spanned Headers( 0 ),
		Suppress Hidden Rows( 1 ),
		Suppress Hidden Columns( 1 ),
		Suppress Empty Columns( 1 ),
		Treat as Hierarchy( 0 ),
		Multiple Series Stack( 0 ),
		Import Cell Colors( 0 ),
		Limit Column Detect( 0 ),
		Column Separator String( "-" )
	)
);

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Script for add-in to allow user pick file in a directory

The 

Pick File()

needs to be executed prior to the Open().

Below is an example of how to get what you  specified

//Open  Table
Names Default To Here( 1 );
file = Pick File(
	"Select the Excel file to input",
	"$DOCUMENTS",
	{"Excel Files|xlsx;xlsm;xls", "All Files|*"},
	1,
	0
);
If( file != "",
	dt1 = Open(
		file,
		Worksheets( {"Merge1"} ),
		Use for all sheets( 1 ),
		Concatenate Worksheets( 1 ),
		Create Concatenation Column( 0 ),
		Worksheet Settings(
			1,
			Has Column Headers( 1 ),
			Number of Rows in Headers( 1 ),
			Headers Start on Row( 1 ),
			Data Starts on Row( 2 ),
			Data Starts on Column( 1 ),
			Data Ends on Row( 0 ),
			Data Ends on Column( 0 ),
			Replicated Spanned Rows( 1 ),
			Replicated Spanned Headers( 0 ),
			Suppress Hidden Rows( 1 ),
			Suppress Hidden Columns( 1 ),
			Suppress Empty Columns( 1 ),
			Treat as Hierarchy( 0 ),
			Multiple Series Stack( 0 ),
			Import Cell Colors( 0 ),
			Limit Column Detect( 0 ),
			Column Separator String( "-" )
		)
	)
);

The Pick File() function is well documented along with an example in the Scripting Index.

Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: Script for add-in to allow user pick file in a directory

The 

Pick File()

needs to be executed prior to the Open().

Below is an example of how to get what you  specified

//Open  Table
Names Default To Here( 1 );
file = Pick File(
	"Select the Excel file to input",
	"$DOCUMENTS",
	{"Excel Files|xlsx;xlsm;xls", "All Files|*"},
	1,
	0
);
If( file != "",
	dt1 = Open(
		file,
		Worksheets( {"Merge1"} ),
		Use for all sheets( 1 ),
		Concatenate Worksheets( 1 ),
		Create Concatenation Column( 0 ),
		Worksheet Settings(
			1,
			Has Column Headers( 1 ),
			Number of Rows in Headers( 1 ),
			Headers Start on Row( 1 ),
			Data Starts on Row( 2 ),
			Data Starts on Column( 1 ),
			Data Ends on Row( 0 ),
			Data Ends on Column( 0 ),
			Replicated Spanned Rows( 1 ),
			Replicated Spanned Headers( 0 ),
			Suppress Hidden Rows( 1 ),
			Suppress Hidden Columns( 1 ),
			Suppress Empty Columns( 1 ),
			Treat as Hierarchy( 0 ),
			Multiple Series Stack( 0 ),
			Import Cell Colors( 0 ),
			Limit Column Detect( 0 ),
			Column Separator String( "-" )
		)
	)
);

The Pick File() function is well documented along with an example in the Scripting Index.

Jim