Login  Register

Re: Macro help - result file save

Posted by Michael Schmid on Nov 22, 2013; 4:31pm
URL: http://imagej.273.s1.nabble.com/Macro-help-result-file-save-tp3694038p5005661.html

Hi Lodi,

To change the filenames is simple macro programming; it would be worthwhile learning it...
To start, see the macro documentation at
  http://rsb.info.nih.gov/ij/developer/macro/macros.html
  http://rsb.info.nih.gov/ij/developer/macro/functions.html
  http://fiji.sc/Introduction_into_Macro_Programming

In the current case, instead of
  name = getTitle();
  index = lastIndexOf(name, ".");
  if (index!=-1) name = substring(name, 0, index);
  name = name + ".csv";
  saveAs("Measurements", dir+name);
you can use something like the following (I have not tried, there may be errors in it)
  name = getTitle();
  index = lastIndexOf(name, ".");
  if (index!=-1) name = substring(name, 0, index);
  maxLength = 30;
  length = lengthOf(name);
  if (length > maxLength)
    name = substring(name, length-maxLength);
  name = name + ".csv";
  saveAs("Measurements", dir+name);

For renaming the Excel sheets without having a different filename, you have to search the Excel or VBA documentation...

Michael
________________________________________________________________
On Nov 22, 2013, at 16:09, Lodi wrote:

> Actually I have another question about this macro. Does anybody know if it is
> possible to name the sheets from the excel files only after the last 30
> characters from the TIF file name.
>
> It would be the best if the excel files are still named after the whole TIF
> file name, but if it's not possible to change the sheet name without
> changing the excel file name, its alright to change the excel file name as
> well.
>
> My problem is that the TIF files have names which are way longer than 31
> characters (max sheet name in excel). I need to do some further analysis
> with the excel files afterward; these analysis are interrupted because of
> the wrong sheet name.
>
> Again I would greatly appreciate any help with this!
>
> Lodi.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html