How to use variables in the "file=" parameter of the "Read_and_Write_Excel" plugin by antinos

Oh boy my first forum post,

I just recently started writing Fiji macros, so maybe it is just my lack of knowledge or so obvious that I find the info nowhere, but how do I use a variable as a file path for the Read_and_Write_Excel plugin or is it just not possible?

If I use the standard command modified to my file path:

run(“Read and Write Excel”, “file=[C:/Users/Henning/Desktop/Fiji Macro 2021/Results] file_mode=read_and_open”);

everything works fine and i get a file containing all measurements my macro takes and processes, but if I try to enable user input on the file path and naming without having to hardcode it into the script each time by using a variable (here: outputDir), I can’t get it to work.
I tried the following examples:

outputDir = “C:/Users/Henning/Desktop/Fiji Macro 2021/Results”

run(“Read and Write Excel”, “file=[outputDir] file_mode=read_and_open”);

run(“Read and Write Excel”, “file=”[outputDir] “file_mode=read_and_open”);

run(“Read and Write Excel”, “file=”[outputDir]" file_mode=read_and_open");


run(“Read and Write Excel”, “file=”[]+outputDir “file_mode=read_and_open”);

when I got desperate

…but now I ran out of ideas, any help would be greately appreciated!


run("Read and Write Excel", "file=["+outputDir+"] file_mode=read_and_open";

should work.

See this recent thread.

Thank you,

run("Read and Write Excel", "file=["+outputDir+"] file_mode=read_and_open");

worked perfectly, I assume the plusses in, “+outputDir+” tell the script that the variable should be enbedded in the surrounding string?

Thanks again


Please consult the relevant documentation and user manual.