if (frame!=null && (frame instanceof TextWindow)) {
TextPanel tp = ((TextWindow)frame).getTextPanel();
tp.saveAs("");
} else if (frame!=null && (frame instanceof Editor)) {
Editor ed = (Editor)frame;
ed.saveAs();
} else {
IJ.error("Save As Text",
"This command requires a TextWindow, such\n"
+ "as the \"Log\" window, or an Editor window. Use\n"
+ "File>Save>Text Image to save an image as text.");