cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Have your say in shaping JMP's future by participating in the new JMP Wish List Prioritization Survey
Choose Language Hide Translation Bar
Sebastienlg
Level II

Return of an error to the user because of a wrong Excel file selected

Hello, 

I would like to create a JMP program which returns an error to the user because he selected the wrong Excel file.

 

Here is an example of my program:

The  file_path contains the path to the file selected by the user.

However, I would like to return a message error when the Worksheets( "AAA" ) is not contained in the Excel file selected by the user: because he didn't choose the right Excel file.  

 

Funct = Function( {file_path, visib},
	Eval(
		Eval Expr(
			myTable = Open(
				file_path, 
				Worksheets( "AAA" ),
				Use for all sheets( 1 ),
				Concatenate Worksheets( 0 ),
				..
				),
				Expr( visib )
			)
		)
	);

Is it possible to make an if condition ? If the file selected doesn't contains the worksheet in question, then JMP returns the message error ?

However, I don't know how to make it.

Does anyone have a solution?

Thank you very much for your answer,

Sébastien

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Return of an error to the user because of a wrong Excel file selected

There is a function called Get Excel Worksheets(). You can combine it with Throw() or make your own modal window for example

Names Default To Here(1);
sheetList = Get Excel Worksheets(
	"$SAMPLE_IMPORT_DATA\Team Results.xlsx"
);
If(!Contains(sheetList, "AAA"), 
	Throw("No 'AAA' found from excel sheet list");
);
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Return of an error to the user because of a wrong Excel file selected

There is a function called Get Excel Worksheets(). You can combine it with Throw() or make your own modal window for example

Names Default To Here(1);
sheetList = Get Excel Worksheets(
	"$SAMPLE_IMPORT_DATA\Team Results.xlsx"
);
If(!Contains(sheetList, "AAA"), 
	Throw("No 'AAA' found from excel sheet list");
);
-Jarmo
Sebastienlg
Level II

Re: Return of an error to the user because of a wrong Excel file selected

Thanks a lot it works!