Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to figure out how to print a message dialog without printing the whole notebook. FrontEndExecute[FrontEndToken["PrintDialog"]] displays the print window (just like selecting file -> print but it prints the whole notebook. I have also tried using FrontEndExecute[FrontEndToken["PrintSelectionDialog"]] but when the code is run the selected area becomes unselected.

I have solved part of the problem with the following

  DialogNotebook[{Column[{Plot[Sin[x], {x, 0, 6 Pi}], 

This prints the entire window including the print button as shown.
print output
This is exactly what I am looking for but without the print button.
Any ideas much appreciated,

share|improve this question
If you mean a message dialog that you code yourself. Consider creating a notebook on the fly that you format, size, and configure to operate as a message dialog. A bit of a heavy handed workaround but that should give you all the flexibility you need. Easier to answer if you give more a specific example and some code. – Jagra Aug 2 '12 at 19:45
Your question is not too well specified. I tried to provide a couple of general examples below, but if you will give more context for your problem I will try to be more specific myself. – Mr.Wizard Aug 2 '12 at 22:14
I appreciate the update. I tried to find a solution to print everything but the button but I could not. Hopefully someone with FrontEnd expertise will be able to. – Mr.Wizard Aug 5 '12 at 7:41
up vote 1 down vote accepted

It is not clear to me from your question how you want to use this operation. If you create a Button with this code you should be able to click the button to print a selected block of code.

Button["Print Selection",
  FrontEndTokenExecute @ "PrintSelectionDialog"

If you want to perform this operation programmatically you need to control the selection with e.g. SelectionMove.

 SelectionMove[EvaluationNotebook[], All, EvaluationCell];
 FrontEndTokenExecute @ "PrintSelectionDialog"

You can move the selection to a different Cell or Notebook if needed. In addition to the documentation for SelectionMove read: Manipulating Notebooks from the Kernel.

share|improve this answer
Thanks for the help. In the end I created a button to execute NotebookPrint[CreateDocument[stuff to be printed]] – Christina Aug 16 '12 at 15:43
@Christina you're welcome; I'm sorry I didn't have something more specific for you, but I'm glad you found something that works for your application. – Mr.Wizard Aug 17 '12 at 0:53

Is this what you are looking for?

PrintMessage[expr_] := NotebookWrite[MessagesNotebook[],
share|improve this answer
Since Mr.Wizard's answer was accepted with the fact it does something different than yours, I think your answer isn't on topic. But I agree the question itself may be vague. – Kuba Apr 15 '15 at 7:22
True, but the key idea was "how to print a message dialog", which wasn't really answered. – M.R. Apr 15 '15 at 19:15
+1 Not sure what the OP was really looking for, but when I searched for writing to the Message window, this answer came up, and that's what I was looking for. – bobthechemist May 24 '15 at 12:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.